11.05.2016 Views

Apache Solr Reference Guide Covering Apache Solr 6.0

21SiXmO

21SiXmO

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Rollback Operations<br />

The rollback command rolls back all add and deletes made to the index since the last commit. It neither calls any<br />

event listeners nor creates a new searcher. Its syntax is simple: .<br />

Using curl to Perform Updates<br />

You can use the curl utility to perform any of the above commands, using its --data-binary option to<br />

append the XML message to the curl command, and generating a HTTP POST request. For example:<br />

curl http://localhost:8983/solr/my_collection/update -H "Content-Type: text/xml"<br />

--data-binary '<br />

<br />

<br />

Patrick Eagar<br />

Sports<br />

796.35<br />

0002166313<br />

1982<br />

Collins<br />

<br />

'<br />

For posting XML messages contained in a file, you can use the alternative form:<br />

curl http://localhost:8983/solr/my_collection/update -H "Content-Type: text/xml"<br />

--data-binary @myfile.xml<br />

Short requests can also be sent using a HTTP GET command, URL-encoding the request, as in the following.<br />

Note the escaping of "":<br />

curl http://localhost:8983/solr/my_collection/update?stream.body=%3Ccommit/%3E<br />

Responses from <strong>Solr</strong> take the form shown here:<br />

<br />

<br />

0<br />

127<br />

<br />

<br />

The status field will be non-zero in case of failure.<br />

Using XSLT to Transform XML Index Updates<br />

The UpdateRequestHandler allows you to index any arbitrary XML using the parameter to apply an XSL<br />

transformation. You must have an XSLT stylesheet in the conf/xslt directory of your config set that can<br />

transform the incoming data to the expected format, and use the tr parameter to specify<br />

the name of that stylesheet.<br />

Here is an example XSLT stylesheet:<br />

<strong>Apache</strong> <strong>Solr</strong> <strong>Reference</strong> <strong>Guide</strong> <strong>6.0</strong><br />

186

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!