Aggregate through pages

We have a query which returns a large number of results, sorted alphabetically and we're using a pagination to iterate through these pages.
I wonder: can we use aggregations to get the page, containing the element with the largest score?

Just for example, we have 10 results of query (match: "Foo") in 4 pages, sorted alphabetically:

  1. A Foo | (score 1)
  2. B Foo | (score 1)
  3. C Foo | (score 1)

  1. D Foo | (score 1)
  2. E Foo | (score 1)
  3. Foo | (score 2)

  1. G Foo | (score 1)
  2. H Foo | (score 1)
  3. I Foo | (score 1)

  1. Foo | (score 1)

How can we get something like that?

top result:
| Foo
top page:
| Number: 2
| Content:
| 4. D Foo | (score 1)
| 5. E Foo | (score 1)
| 6. Foo

I am not sure I follow that request. If the from and size parameters are not doing what you expect them to do, then explain a bit further. See https://www.elastic.co/guide/en/elasticsearch/reference/7.6/search-request-body.html#request-body-search-from-size

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