Max Clause Count-Passing Cluster of Ids (integer)

Hi,

We have a case where we want to send list of ids (integer) based on user selection in the UI to ElasticSearch to perform search operation with sort of (in) operation. I tried to use TermsQuery but ran into Max Clause count issue of 1024. I saw the options such as

  1. using range query - Cant use that as it is based on what user selects in UI , so the ids need not be sequential
  2. Term lookup - again this does not seem to fit into that category
  3. Increase the max clause count threshold - read that it is not desirable and could easily eat up the memory but not sure about this.

Please guide what is the best practice in these cases .

Regards
Raghav

You can do multiple sets of Terms in a bool. e.g.

bool:
  should:
    terms: [...]
    terms: [...] 
    terms: [...] 

Not really ideal, but it'll work. I think the bigger question is why do you need > 1024 individual terms? If the user is selecting these via a UI, there must be some organization to the IDs that you could search for instead?

Or if they are searching ranges of IDs, you could setup multiple ranges instead big chunks of individual terms:

bool:
  should:
    range: [...]
    terms: [...] 
    range: [...] 

etc

Thank you . Appreciate your response.

Actually these are city ids . So based on your response I have done these

  1. Clubbed cityids and pass countrycode if all city ids are selected in UI
  2. Implemented range filter wherever it is not possible to do the above
  3. Finally still to be safe have split it into multiple terms.

It works but will check from the performance perspective . Thanks again!