The XSLT UpdateRequestHandler lets you index arbitrary XML documents to Solr using on-the-fly XSLT transformation to Solr's update XML.

<!> Solr3.4

Requirements

<!> In Solr4.0, XSLT support is included in the standard XML UpdateRequestHandler

  <requestHandler name="/update" class="solr.UpdateRequestHandler"/>

Note, requests need to include Content-type:application/xml or Content-type:text/xml

When the "tr=XXX" parameter is present, it will be used to transform the incomming XML

<!> Solr3.4 is the first version with XSLT support for updates.

The XSLT request handler needs to be configured in solrconfig.xml This should already be present in the example solrconfig.xml

  <!-- XSLT Update Request Handler
       Transforms incoming XML with stylesheet identified by tr=
  -->
  <requestHandler name="/update/xslt"
                   startup="lazy"
                   class="solr.XsltUpdateRequestHandler"/>

Methods of uploading XML files

An arbitrary XML for which you have a transformation stylesheet may be uploaded to Solr by sending the data to the /solr/update/xslt URL, and specifying the stylesheet in the &tr=mySheet.xsl parameter. All of the normal methods for uploading content are supported.

Examples

Transform query result XML

Indexing a Solr XML query result file. This could be an export from an older search index that you want to migrate. For this we have a style sheet updateXml.xsl which was new in <!> Solr3.6

  1. Download the search result xml, let's call it "queryresult.xml"
  2. Feed your data through XSLT update handler selecting the correct style sheet

curl "http://localhost:8983/solr/update/xslt?commit=true&tr=updateXml.xsl" -H "Content-Type: text/xml; charset=utf-8" --data-binary @queryresult.xml

XsltUpdateRequestHandler (last edited 2012-05-08 21:45:52 by ryan)