Hello, i have a question how to eval script which can be stored inside a field.
For example, i want to define rules for calculation inside documents. Let's see on this mapping:
index: rules
{
"properties": {
"price_rule": { "type": "keyword" }
}
}
Then i add document:
curl -X PUT localhost:9200/rules/_doc/1 -d '{"price_rule": " if (params.Age <= 60) { return 20 } else { return 30}"}' -H "Content-Type: application/json"
And i want todo a request for search, where i can send para age and see which documents has price_rule > 20 as example.
{
"query": {
"bool" : {
"filter" : {
"script" : {
"script" : {
"source" : "doc['price_rule'].value",
"lang" : "painless",
"params" : {
"Age" : "60"
}
}
}
}
}
}
}
How i can eval script inside field and pass params?