I have to query elasticsearch for sum of two fields in a doc, that fall in a particular range.
I'm trying to create a Java API for the below elastic search query, but not able to make out how to include script tags and select doc elements i.e doc['maintenanceCost']. Any help would be appreciated.
{
"query": {
"bool" : {
"filter" : {
"script" : {
"script" : "doc['price'].value + doc['maintenanceCost'].value > 1000 && doc['price'].value + doc['maintenanceCost'].value < 10000"
}
}
}
}
}
I basically need docs in which sum of price andenter code here maintenance cost fall between 1000 to 10000
I have tried out few queries like ScriptBuilders, but none of them worked