Unique array elements in elasticsearch 7.4.2

Hi, I've found this post and I think it's a little old. I run this code in elasticsearch 7.4.2 :

POST logstash-vod-2020.11/_update_by_query?conflicts=proceed&refresh
{
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "tags.keyword": "SomeTag"
          }
        }
      ]
    }
},
 "script": {
    "inline": "ctx._source.ts_duration=ctx._source.ts_duration.stream().distinct().sorted().collect(Collectors.toList())"
  }
}

and I get this error:

{
  "error": {
    "root_cause": [
      {
        "type": "script_exception",
        "reason": "runtime error",
        "script_stack": [
          "ctx._source.ts_duration=ctx._source.ts_duration.stream().distinct().sorted().collect(Collectors.toList())",
          "                                               ^---- HERE"
        ],
        "script": "ctx._source.ts_duration=ctx._source.ts_duration.stream().distinct().sorted().collect(Collectors.toList())",
        "lang": "painless"
      }
    ],
    "type": "script_exception",
    "reason": "runtime error",
    "script_stack": [
      "ctx._source.ts_duration=ctx._source.ts_duration.stream().distinct().sorted().collect(Collectors.toList())",
      "                                               ^---- HERE"
    ],
    "script": "ctx._source.ts_duration=ctx._source.ts_duration.stream().distinct().sorted().collect(Collectors.toList())",
    "lang": "painless",
    "caused_by": {
      "type": "illegal_argument_exception",
      "reason": "dynamic method [java.lang.Integer, stream/0] not found"
    }
  },
  "status": 400
}

I try source instead of inline but I get same error. what is the problem ? thanx

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