I have troubles to execute the following painless script (used inside a FunctionScoreQuery):
1200 * Math.pow((doc.containsKey(params.population_key) ? doc[params.population_key].value : 0), 0.05)
The params.population_key is a string and the field is present only in some documents, it's mapping is defined as a dynamic template of type double.
The execution works but logs following error:
returning default values for missing document values is deprecated. Set system property '-Des.scripting.exception_for_missing_value=true' to make behaviour compatible with future major versions!
It seems to me that the true branch of the ternary expression is evaluated eagerly, maybe because some kind of type conversion or so? Could you please suggest a way how to rewrite the script so I don't get any warning?