Specifies how to get the next page of results in a search.
A cursor returned in a previous set of search results to use as a starting
point to retrieve the next set of results. This can get you better
performance, and also improves the consistency of pagination through index
updates.
The following shows how to use the cursor to get the next page of results:
# get the first set of results; the first cursor is used to specify
# that cursors are to be returned in the SearchResults.
results = index.search(Query(query_string='some stuff',
QueryOptions(cursor=Cursor()))
# get the next set of results
results = index.search(Query(query_string='some stuff',
QueryOptions(cursor=results.cursor)))
If you want to continue search from any one of the ScoredDocuments in
SearchResults, then you can set Cursor.per_result to True.
# get the first set of results; the first cursor is used to specify
# that cursors are to be returned in the SearchResults.
results = index.search(Query(query_string='some stuff',
QueryOptions(cursor=Cursor(per_result=True)))
# this shows how to access the per_document cursors returned from a search
per_document_cursor = None
for scored_document in results:
per_document_cursor = scored_document.cursor
# get the next set of results
results = index.search(Query(query_string='some stuff',
QueryOptions(cursor=per_document_cursor)))