Hey guys,
I just have a question about a nested query I’m trying to do. So I have a index with a nested object. In that nested object I have two range types a date range and a double range.
I want to create a query where “Everything between these dates AND this double range”.
Here’s a query that works for one at a time:
GET partition/_search
{
"query": {
"nested": {
"path": "specs",
"query": {
"bool": {
"must": [
{ “term":
{"specs.key": "timestamp"}
},
{ "range":
{"specs.date_range": {
"gte":"1970-01-29T00:41:00"}
}
}
]
}
}
}
}
}
I’m just trying to extend this to work with the double range. I seem to only be able to get one to work at a time otherwise nothing is returned. Here is my attempt of searching both ranges.
GET partition/_search
{
"query": {
"nested": {
"path": "specs",
"query": {
"bool": {
"must": [
{"term":
{"specs.key":"timestamp"}
},
{ "range":
{"specs.date_range": {
"gte":"1970-01-29T00:41:00"}
}
},
{
"term":{"specs.key”:"cost"}
},
{
"range": {"specs.cost_range": {
"gte": 10,
"lte": 20
}
}
}
]}
}
}
}
}
Here’s an example entry that SHOULD match that query I made:
{
"_index" : "partition",
"_type" : "_doc",
"_id" : "0",
"_score" : 1.0,
"_source" : {
"specs" : [
{
"key" : "timestamp",
"date_range" : {
"gte" : 2487372217,
"lte" : 2546383872
}
},
{
"key" : “cost",
“cost_range" : {
"gte" : 0,
"lte" : 0
}
}
]
}
}
Thanks for any help you’re able to provide!