Hi,
I am trying to get a query similar to the one below working. The
ranges may not necessarily be consecutive so I need to be able to
retrieve all of the documents that satisify this requirement. Also,
potentially I will need to add other filters so this should work with
the "AND" filter or something equivalent.
{
"query": {"match_all":{} },
"filter" : {
"range" : {
"file_size" : [
{ "from" : 100, "to" : 10000 },
{ "from" : 1000001, "to" : 10000000 } ]
}
}
}
What I have tried is below:
- bool filter with two must clauses with the range to search
{
"query": {"match_all":{} },
"filter" : {
"bool" : {
"must" : {"range" : {
"file_size" :
{ "from" : 10, "to" : 10000 }}},
"must" : {"range" : {
"file_size" :
{ "from" : 10001, "to" : 1000000 }
}}}
}
}
- two separate "AND" queries in a single "FILTER"
{
"query": {"match_all":{} },
"filter" : {
"and" : [{"range" : {
"file_size" :
{ "from" : 10, "to" : 10000 }}}],
"and" : [{"range" : {
"file_size" :
{ "from" : 10001, "to" : 1000000 }}}]
}
}
- Combo "AND" and "OR" in a single filter element
{
"query": {"match_all":{} },
"filter" : {
"and" : [{"term" :
{"file_stages_filetype_result_extension":"htm"}}],
"or" : [{"range" : {
"file_size" :
{ "from" : 10, "to" : 10000 }}},
{"range" : {
"file_size" :
{ "from" : 10001, "to" : 1000000 }}}]
}
}
- Combo "AND" and "OR" with two different filters, the result seems
to OR both filters
{
"query": {"match_all":{} },
"filter" : {
"or" : [{"range" : {
"file_size" :
{ "from" : 10, "to" : 10000 }}},
{"range" : {
"file_size" :
{ "from" : 120001, "to" : 1000000 }}}]
} ,
"filter" : {
"and" : [{"term" :
{"file_stages_filetype_result_extension":"htm"}}]
}
}
- Single "AND" query with multiple "RANGE" queries on the same field
{
"query": {"match_all":{} },
"filter" : {
"and" : [{"range" : {
"file_size" :
{ "from" : 10, "to" : 10000 }}},
{"range" : {
"file_size" :
{ "from" : 10001, "to" : 1000000 }}}
],
}
}
Nothing seems to work for what I want it to do. Is there a workaround
I can do to get the results I expect?
Vinny