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.

when fetching all docs, you might as well use a simple id sort<br />

// unless you really need the docs to come back in a specific order<br />

$params = [ q => $some_query, sort => 'id asc', rows => $r, cursorMark => '*' ]<br />

$done = false<br />

while (not $done) {<br />

$results = fetch_solr($params)<br />

// do something with $results<br />

if ($params[cursorMark] == $results[nextCursorMark]) {<br />

$done = true<br />

}<br />

$params[cursorMark] = $results[nextCursorMark]<br />

}<br />

Using <strong>Solr</strong>J, this psuedo-code would be:<br />

<strong>Solr</strong>Query q = (new <strong>Solr</strong>Query(some_query)).setRows(r).setSort(SortClause.asc("id"));<br />

String cursorMark = CursorMarkParams.CURSOR_MARK_START;<br />

boolean done = false;<br />

while (! done) {<br />

q.set(CursorMarkParams.CURSOR_MARK_PARAM, cursorMark);<br />

QueryResponse rsp = solrServer.query(q);<br />

String nextCursorMark = rsp.getNextCursorMark();<br />

doCustomProcessingOfResults(rsp);<br />

if (cursorMark.equals(nextCursorMark)) {<br />

done = true;<br />

}<br />

cursorMark = nextCursorMark;<br />

}<br />

If you wanted to do this by hand using curl, the sequence of requests would look something like this:<br />

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

350

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

Saved successfully!

Ooh no, something went wrong!