Solr sends results one page at a time: rows says how many, start says from which position, counting from 0.
01 · rows and start
| Page | Parameters | Results |
|---|---|---|
| 1 | start=0&rows=10 | 1 to 10 |
| 2 | start=10&rows=10 | 11 to 20 |
| N | start=(N−1)×rows |
var rows = 10; var pages = Math.ceil(data.response.numFound / rows); var current = Math.floor(data.response.start / rows) + 1;
02 · Deep pages cost more
To answer start=100000&rows=20, Solr ranks the first 100,020 results again, on every request. Show a few hundred pages at most and refuse deeper requests in your own code. Opensolr checks the traffic of every index daily and emails you when it sees requests deeper than start=100000, which is how a scraper walking your index usually looks.
03 · Every document: cursorMark
To read a whole index (an export, a migration), use a cursor. Its cost stays the same on every page, however deep:
q=*:*&sort=id asc&rows=500&cursorMark=*
Each answer carries nextCursorMark. Send it as cursorMark in the next request, with the same query and sort.
When nextCursorMark comes back equal to the one you sent, you have every document.
The sort must end with id, and the request must not send start.
04 · Next
Order results by date, price or any field.
The request and the parameters that matter.
How many results the hosted search page shows.