Elasticsearch painless script error
You're simply missing the .value
to access the field value.
Your script needs to be like this instead:
double price = doc['newPrice'].value > 0.0 ? doc['price'].value / doc['newPrice'].value : 0; _score * params.constant * price
doc['newPrice']
is different from
doc['newPrice'].value
You should use the later