I am trying to make a query in elastic search that will do the following: I want it to check for a result that has (metropolitan_area of 16 AND starts_at of 05072013) OR (metropolitan_id of 16 AND starts_at "blank".
This is my current query, but I feel like it needs to be nested somehow and I am unsure how to do that.
{
"query" : {
"bool" : {
"must" : [
{
"term" : {"user" : "a"}
},
{
"term" :{"metropolitan_area" : "16"}
}
],
"must_not" : [],
"should" : []
}
},
"filter" : {
"or" : {
"filters" : [
{
"term" : {"user":"519"}
},
{
"term" : {"user":"6"}
},
{
"term" : {"user":"5"}
},
{
"term" : {"user":"36"}
},
{
"term" : {"starts_at":"05072013"}
},
{
"term" : {"starts_at":"blank"}
}
]
}
}
}
The correctly nested boolean expression is shown below:
{
"filter": {
"or" : [{
"and" : [
{ "term" : { "metropolian_area" : 16 } },
{ "term" : { "starts_at" : 0123213 } }
]
}, {
"and" : [
{ "term" : ... },
{ "term" : ... }
]
}]
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With