1

i'm trying to get some data based on query with elastic4s in scala using search_after because i have more then 10 000 items.

I'm trying something like this:

client.execute(
   search(index).query(q).searchAfter(id).from(start).limit(limit)
)

But it's not working. When i delete that searchAfter, it's working fine but only for first 10 000 items. I'm new with elastic so any help will be appreciated. Thanks

1 Answers1

0

elasticsearch will always return a maximum of 10,000 results on a regular search. when you need to page beyond 10,000 results (in a batch process for instance) you should use the Scroll feature and not a regular search. this will let you "scroll" through all the results in your query, page by page, until the query returns no results. note that the Scroll feature does not allow Sorting.

read more here: Scroll API

Tom Elias
  • 751
  • 6
  • 15
  • 1
    I'm not using regular search. I need to use search_after. I need to paginate then the data and scroll is not that good for pagination. I'm trying to use search_after but it's not working and i don't know where i made a mistake in that code which i posted – asesino2258 Aug 11 '21 at 06:44