Query on search_after

Hi,

One of the column in my database has value of ascending order of time(basically session, so multiple documents belonging to that session have same value ).
I have a requirement of deep scrolling[matches could be in range of millions]and i want the records to be retrieved in the ascending order of the session id.

I am considering of search_after over others such as scroll etc and want to use document _id as the tie breaker.

Snippet from search_after documentation:

"A field with one unique value per document should be used as the tiebreaker of the sort specification. Otherwise the sort order for documents that have the same sort values would be undefined. The recommended way is to use the field _id which is certain to contain one unique value for each document."

Wonder whether this would a way to go. Thank you for any valuable suggestion.

The _id will always be unique within a shard, as this is not the same as your session id.

So you probably would want to sort by time, session id and _id, if I understood you correctly.

--Alex

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.