I have a search query something like this: ((q1 AND q2) OR (q3 AND q4))
. I can replicate it using must
, should
in Elasticsearch's search
or scroll
API query. But I want to know how many such queries can be combined in single query in Elasticsearch. I have around 1000 OR
queries, will it have negative impact on performance if I pass 1000 queries in should
clause? And is there any limit on number of queries? I know there is limit on clause of query which can be max_clause_count
. Is there similar limit on number of queries?
Asked
Active
Viewed 50 times
0

Rohanil
- 1,717
- 5
- 22
- 47
1 Answers
0
There is no hardcoded limitation.
This will depend on your hardware and data, try it and ask question if you got any error!
To improve:
- Use
filter
- Use
constant_score
to "disable" tf/idf calcul (https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-constant-score-query.html)
Just by curiosity, why do you need 1000 queries?

Thomas Decaux
- 21,738
- 2
- 113
- 124
-
Initially I had one query which used to return huge amount of documents but I don't need all of them always. Most of the times, I need only few of them. The initial query used to take a lot of time because of no. of docs and serialisation/deserialisation time. so I thought to make a combined query to return optimum amount of documents. Eventually it became a combined query of so many queries. Its not always 1000 queries, it is a worst scenario. Sometimes just 10 queries. I just want to check if there is any limit over no. of queries so I can change to old solution or something else. – Rohanil Oct 12 '17 at 14:34
-
Maybe you should describe your use case, give a data sample and a query, so we can help you to improve it. – Thomas Decaux Oct 12 '17 at 16:00