Elastic pagination for query parameters


(guy) #1

Hi,
Say I have a terms query that potentially could include many parameters..
for example, I have a document which looks like this:

doc {
fieldA: 'id' (string, keyword type)
}

and I also have a list of string values {'id1', 'id2', 'id3',.........}.
the size of the list could potentially be very big (hundreds / thousands and in a very rare cases - Tens of thousands).

and I would like to read all documents that their fieldA contained in one of a list values.

now, I have read in ES docs, that for such queries, it could be that the recommended way doing things is to fetch the parameters from an index.

When it’s needed to specify a terms filter with a lot of terms it can be beneficial to fetch those term values from a document in an index
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-query.html

but I couldn't find any reference about using a different strategy, which is - pagination - split the list to parts, each in 1K size (for example), and read in bulks of 1K.

are there any disadvantages in the pagination approach that I am missing?
as we prefer not to store a temporary doc type only for query parameters..

Thanks