Painless is not that painless


I am a simple thing, like assigning a text to a string variable, and then just return the value. But I keep getting compile error:

if (!doc.containsKey("url.query") || doc["url.query"].empty) {
   return null;

String params = "hej";

return params;

The compiler error is with the String type? What am i doing wrong. I think the painless very often, can painfull instead.


Where are you doing this script?
What is the mapping of the field you are trying to run a script against?

I am assuming you are doing a script against a field that isn't a String.

I was creating a scripted field in Kibana. I solved the problem by changing the variable name from params to tmp??? I didn't know params is reserved word.

1 Like

I know it's reserved in Painless Lab but wouldn't think it carries over from that. Guess it's also used in templates and queries, passing in params.