11.05.2016 Views

Apache Solr Reference Guide Covering Apache Solr 6.0

21SiXmO

21SiXmO

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

$ curl '...&rows=10&sort=id+asc&cursorMark=*'<br />

{<br />

"response":{"numFound":32,"start":0,"docs":[<br />

// ... 10 docs here ...<br />

]},<br />

"nextCursorMark":"AoEjR0JQ"}<br />

$ curl '...&rows=10&sort=id+asc&cursorMark=AoEjR0JQ'<br />

{<br />

"response":{"numFound":32,"start":0,"docs":[<br />

// ... 10 more docs here ...<br />

]},<br />

"nextCursorMark":"AoEpVkRCREIxQTE2"}<br />

$ curl '...&rows=10&sort=id+asc&cursorMark=AoEpVkRCREIxQTE2'<br />

{<br />

"response":{"numFound":32,"start":0,"docs":[<br />

// ... 10 more docs here ...<br />

]},<br />

"nextCursorMark":"AoEmbWF4dG9y"}<br />

$ curl '...&rows=10&sort=id+asc&cursorMark=AoEmbWF4dG9y'<br />

{<br />

"response":{"numFound":32,"start":0,"docs":[<br />

// ... 2 docs here because we've reached the end.<br />

]},<br />

"nextCursorMark":"AoEpdmlld3Nvbmlj"}<br />

$ curl '...&rows=10&sort=id+asc&cursorMark=AoEpdmlld3Nvbmlj'<br />

{<br />

"response":{"numFound":32,"start":0,"docs":[<br />

// no more docs here, and note that the nextCursorMark<br />

// matches the cursorMark param we used<br />

]},<br />

"nextCursorMark":"AoEpdmlld3Nvbmlj"}<br />

Fetch first N docs, Based on Post Processing<br />

Since the cursor is stateless from <strong>Solr</strong>'s perspective, your client code can stop fetching additional results as soon<br />

as you have decided you have enough information:<br />

while (! done) {<br />

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

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

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

boolean hadEnough = doCustomProcessingOfResults(rsp);<br />

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

done = true;<br />

}<br />

cursorMark = nextCursorMark;<br />

}<br />

How cursors are Affected by Index Updates<br />

Unlike basic pagination, Cursor pagination does not rely on using an absolute "offset" into the completed sorted<br />

list of matching documents. Instead, the cursorMark specified in a request encapsulates information about<br />

the relative position of the last document returned, based on the absolute sort values of that document. This<br />

means that the impact of index modifications is much smaller when using a cursor compared to basic pagination.<br />

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

351

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

Saved successfully!

Ooh no, something went wrong!