0
votes

I know that ElasticSearch has an internal limit on how many clauses you can use in a bool query. This is controlled by the max_clause_count in the ElasticSearch.yml file.

But I thought that this limit did not apply to the values that were passed in the searches

So a query like the following would work, with more than 1024 values in the terms query

{
        "query":{
            "bool":{
                "should":[
                    { "terms": {"id": ["cafe-babe-0000","cafe-babe-0001",... ]}}
                ] 
            }
        }
}

But this query will launch a TooManyClauses Exception. So, in this case, the number of values in the query also counts for this limit. Is it correct?

Also, I now that it's not the best way to perform this kind of queries, but Is it possible to rewrite the previous query so that the limit is not exceeded?

1

1 Answers

1
votes

You can use the ids query.

"query": {
    "ids": {
        "values": [ "cafe-babe-0000","cafe-babe-0001",... ]
    }
}

For the best of i know there is no limitation on this query.