I have the following data set.
POST /my_store/products/_bulk
{ "index": { "_id": 1 }}
{ "price" : 10, "productID" : "XHDK-A-1293-#fJ3" }
{ "index": { "_id": 2 }}
{ "price" : 20, "productID" : "KDKE-B-9947-#kL5" }
{ "index": { "_id": 3 }}
{ "price" : 30, "productID" : "JODL-X-1937-#pV7" }
{ "index": { "_id": 4 }}
{ "price" : 30, "productID" : "QQPX-R-3956-#aD8" }
Corresponding to following SQL statement.
select product
from products
where (price = 20 or productID = 'XHDK-A-1293-#fJ3')
and (price != 30)
I have a DSL query in Elasticsearch.
GET /my_store/products/_search
{
"query":{
"constant_score": {
"filter": {
"bool":{
"should":[
{"term":{"price":20}},
{"term":{ "productID" : "XHDK-A-1293-#fJ3"}}
],
"must_not":{
"term" : {"price" : 30}
}
}
}
}
}
}
Why have we not used a must between the conditions
"should":[
{"term":{"price":20}},
{"term":{ "productID" : "XHDK-A-1293-#fJ3"}}
]
and
"must_not":{
"term" : {"price" : 30}
}
Thanks