I am trying to filter results with script query. I can access parameter values with hardcoded field value like this:
"script": "doc['price'].value * params.1000 > 4000",
"params": {"1000": "1.75"}
But if I try to get field value with doc there is no filtering and I can see all results.
"script": "doc['price'].value * params.doc['rate'] > 4000",
"params": {"1000": "1.75"}
Is there any solution to dynamically get parameter value?
EDIT:
The Field 'rate' is just the ID. It is Integer but it is not value I need. The idea is to pass every time different value, via parameter, instead updating field 'rate' frequently. Hope This is better explanation...
example:
"script": "doc['price'].value * params.doc['rate'] > 4000",
"params": {
"1000": "1.75",
"1001": "3.75",
"1002": "5"
}
if
'price' == 10 &&
'rate' == 1002
result should be: 10 * 5 > 4000
if
'price' == 10 &&
'rate' == 1001
result should be: 10 * 3.75 > 4000
if
'price' == 7 &&
'rate' == 1000
result should be: 7 * 1.75 > 4000
I'm assuming
rate
as aninteger
, if so shouldn't the script look like such. If I've understood your filtering correctly, if not please correct me: