So I guess you wanted to write:
documents with historicalData='false' OR no field "historicalData".
In which case, you can do:
DELETE enrl
POST enrl/_bulk
{"index":{"_id":200}}
{"name":"Espresso Machine","price":199,"in_stock":5,"historicalData":false}
{"index":{"_id":201}}
{"name":"Milk Frother","price":250,"in_stock":15,"historicalData":true}
{"index":{"_id":202}}
{"name":"Toaster","price":199,"in_stock":35,"historicalData":false}
{"index":{"_id":203}}
{"name":"Appetizer","price":200,"in_stock":25,"historicalData":true}
{"index":{"_id":204}}
{"name":"Mixer","price":300,"in_stock":5}
GET enrl/_search
{
"query": {
"bool": {
"should": [
{
"term": {
"historicalData": {
"value": false
}
}
},
{
"bool": {
"must_not": [
{
"exists": {
"field": "historicalData"
}
}
]
}
}
]
}
}
}
Which gives:
{
"took" : 4,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 3,
"relation" : "eq"
},
"max_score" : 0.6931472,
"hits" : [
{
"_index" : "enrl",
"_type" : "_doc",
"_id" : "200",
"_score" : 0.6931472,
"_source" : {
"name" : "Espresso Machine",
"price" : 199,
"in_stock" : 5,
"historicalData" : false
}
},
{
"_index" : "enrl",
"_type" : "_doc",
"_id" : "202",
"_score" : 0.6931472,
"_source" : {
"name" : "Toaster",
"price" : 199,
"in_stock" : 35,
"historicalData" : false
}
},
{
"_index" : "enrl",
"_type" : "_doc",
"_id" : "204",
"_score" : 0.0,
"_source" : {
"name" : "Mixer",
"price" : 300,
"in_stock" : 5
}
}
]
}
}