Painless script ambiguous remove method call

As the following script shows:

  "script": {
    "inline": "ctx._source.users.remove(params.users)",
    "params": {
      "users": 400903
    }
  }

ES complains about index_out_of_bounds_exception which it calls remove(int) but I need it call remove(Object), how to achieve it? Many thanks.

The Painless API is described here (https://www.elastic.co/guide/en/elasticsearch/painless/6.2/painless-api-reference.html). List only contains remove(int) as you have mentioned. The reasons for the way method overloading works in Painless are described here (https://www.elastic.co/guide/en/elasticsearch/painless/current/modules-scripting-painless-dispatch.html).

My suggestion would be to rewrite the script as the following:

ctx._source.users.remove(ctx._source.users.indexOf(params.users))
1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.