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.

Update handlers can also get commit-related parameters as part of the update URL. This example adds a small<br />

test document and causes an explicit commit to happen immediately afterwards:<br />

http://localhost:8983/solr/my_collection/update?stream.body=<br />

testdoc&commit=true<br />

Alternately, you may want to use this:<br />

http://localhost:8983/solr/my_collection/update?stream.body=<br />

This example causes the index to be optimized down to at most 10 segments, but won't wait around until it's<br />

done ( waitFlush=false):<br />

curl<br />

'http://localhost:8983/solr/my_collection/update?optimize=true&maxSegments=10&waitFl<br />

ush=false'<br />

This example adds a small test document with a commitWithin instruction that tells <strong>Solr</strong> to make sure the<br />

document is committed no later than 10 seconds later (this method is generally preferred over explicit commits):<br />

curl http://localhost:8983/solr/my_collection/update?commitWithin=10000<br />

-H "Content-Type: text/xml" --data-binary<br />

'testdoc'<br />

Changing default commitWithin Behavior<br />

The commitWithin settings allow forcing document commits to happen in a defined time period. This is used<br />

most frequently with Near Real Time Searching, and for that reason the default is to perform a soft commit. This<br />

does not, however, replicate new documents to slave servers in a master/slave environment. If that's a<br />

requirement for your implementation, you can force a hard commit by adding a parameter, as in this example:<br />

<br />

false<br />

<br />

With this configuration, when you call commitWithin as part of your update message, it will automatically<br />

perform a hard commit every time.<br />

RealTime Get<br />

For index updates to be visible (searchable), some kind of commit must reopen a searcher to a new point-in-time<br />

view of the index. The realtime get feature allows retrieval (by unique-key) of the latest version of any<br />

documents without the associated cost of reopening a searcher. This is primarily useful when using <strong>Solr</strong> as a<br />

NoSQL data store and not just a search index.<br />

Real Time Get relies on the update log feature, which is enabled by default and can be configured in solrconf<br />

ig.xml:<br />

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

402

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

Saved successfully!

Ooh no, something went wrong!