Combining AND and OR conditions

Find all products in the price range 10 to 13, AND manufactured by valuesoft or pinnacle:

GET /amazon_products/_search
{
"query": {
"constant_score": {
"filter": {
"bool": {
"must": [
{
"range": {
"price": {
"gte": 10,
"lte": 30
}
}
}
],
"should": [
{
"term": {
"manufacturer.raw": {
"value": "valuesoft"
}
}
},
{
"term": {
"manufacturer.raw": {
"value": "pinnacle"
}
}
}
]
}
}
}
}
}

Please note that all conditions that need to be ORed together are placed inside the should element. The conditions that need to be ANDed together, can be placed inside the must element, although it is also possible to put all the conditions to be ANDed in the filter element.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.146.176.68