I have an index with a type called vehicle, I am trying to create a bool query, so if the car built_year is 2001 OR 2003 and if the car has extras like radio AND air conditioner.
This is how I started
{
"query":{
"bool":{
"filter":
[
{
"terms":{
"built_year": [2001,2003]
},
"terms":{
"built_year": [2001,2003]
},
{
"match": {
"attributes.extras.id": 5
}
},
{
"match": {
"attributes.extras.id": 4
}
}
]
}
}
It works as intended, but I was wondering if there is a better way of doing this, specially if I wanna use OR between filters instead of AND, or the right ways is to use nested queries?
The basic idea is to do this programatically, so if I recieve an object filter and it comes with a property operator that has AND or OR values.