Hi there, I have been using cores to built up new cores (because of various reasons). (I am not using SOLR as data storage, the cores are re-indexed frequently.)
This solution works for releases 1.4 and 3 as it does not use the SolrEntityProcessor. To load data from another SOLR core and populate part of the new document I use: (1) in the target data-config.xml: <entity name="content" dataSource="sourceCore" url="solr/gmaContent/select?q=contentid: ${targetDoc.ID}&wt=xslt&tr=response-to-update.xsl" processor="my.custom.handler.dataimport.CachingXPathEntityProcessor" cacheKey="${targetDoc.ID}" useSolrAddSchema="true"> </entity> (2) sourceCore's solrconfig.xml needs an entry (uncomment) for the xslt response writer: <!-- XSLT response writer transforms the XML output by any xslt file found in Solr's conf/xslt directory. Changes to xslt files are checked for every xsltCacheLifetimeSeconds. --> <queryResponseWriter name="xslt" class="solr.XSLTResponseWriter"> <int name="xsltCacheLifetimeSeconds">6000</int> </queryResponseWriter> (2) response-to-update.xsl (this goes into $SOLR_HOME/sourceCore/conf/xslt/): <?xml version='1.0' encoding='UTF-8'?> <xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> <xsl:output method="xml" media-type="text/xml;charset=utf-8" indent="yes" encoding="UTF-8" omit-xml-declaration="no" /> <xsl:template match='/'> <add> <xsl:apply-templates select="/response/result/doc" /> </add> </xsl:template> <xsl:template match="doc"> <doc> <xsl:choose> <xsl:when test="doc/*[name()='arr']"> <xsl:apply-templates select="//arr" /> </xsl:when> <xsl:otherwise> <xsl:apply-templates select="child::node()" /> </xsl:otherwise> </xsl:choose> </doc> </xsl:template> <xsl:template match="//arr"> <xsl:for-each select="child::node()"> <xsl:element name="field"> <xsl:attribute name="name"><xsl:value-of select="../@name"></xsl:value-of> </xsl:attribute> <xsl:value-of select="." /> </xsl:element> </xsl:for-each> </xsl:template> <xsl:template match="child::node()"> <xsl:element name="field"> <xsl:attribute name="name"><xsl:value-of select="@name"></xsl:value-of> </xsl:attribute> <xsl:value-of select="." /> </xsl:element> </xsl:template> </xsl:stylesheet> Cheers, Chantal On Mon, 2011-10-10 at 06:26 +0200, Gora Mohanty wrote: > On Mon, Oct 10, 2011 at 6:30 AM, Pulkit Singhal <pulkitsing...@gmail.com> > wrote: > > @Gora Thank You! > > > > I know that Solr accepts xml with Solr specific elements that are commands > > that only it understands ... such as <add/>, <commit/> etc. > > > > Question: Is there some way to ask Solr to dump out whatever it has in its > > index already ... as a Solr xml document? > > As far as I know, there is no way to do that out of the box. One would get > the contents of each record with a normal Solr query, massage that into > a Solr XML document, and use that to rebuild the index. Have not tried > this, but it should be possible to get the desired output format with the > XsltResponseWriter: http://wiki.apache.org/solr/XsltResponseWriter . > > All in all, it seems easier to me to just reindex from the base source, unless > that is not possible for some reason. > > > Plan: I intend to message that xml dump (add the field + value that I need > > in every doc's xml element) and then I should be able to push this dump back > > to Solr to get data indexed again, I hope. > > Yes, that should be the general idea. > > Regards, > Gora