I have two different range queries & I want to apply one range query within another range query.
But ES does not allow should query to be used in a range query.
Is there any other way to perform this query?
I am trying to replicate SQL's sub-query logic.
I have tried to use "MUST" for two different range queries but my range query contains lot of search ranges and the overall AND combination is very time-intensive.
The basic algorithm will be like:
**Range Query 1**
{
"SHOULD":
{
from: 10,
to: 20,
AND
_Range Query 2_
{
from:0,
to:5
}
},
{
from: 30,
to: 40,
AND
_Range Query 2_
{
from:0,
to:5
}
}
}
I'm also assuming that the second clause of 0..5 isn't going to be the same for every combination, otherwise you could arrange the logic differently, eg:
You are correct. RANGE_QUERY_2 is on a different field and the second clause(0...5) will also be different for every combination.
So, there will be NxN combinations which makes the query too long.
Is there any other way to optimize the above query from performance perspective?
And how will Elastic Search analyze the above query after applying filter context among two range queries?
Because as far as I know, if there is a query context that is executed first, then filter is applied on the results of the query context.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.