elastic/elasticsearch-java

Unknown field in script UpdateRequest data

Kelanor opened this issue · 1 comments

Java API client version

8.7.1

Java version

17

Elasticsearch Version

8.7.1

Problem description

Got an error when trying execute script update

{
  "error": {
    "root_cause": [
      {
        "type": "x_content_parse_exception",
        "reason": "[8:3] [UpdateRequest] failed to parse field [script]"
      }
    ],
    "type": "x_content_parse_exception",
    "reason": "[8:3] [UpdateRequest] failed to parse field [script]",
    "caused_by": {
      "type": "illegal_argument_exception",
      "reason": "illegal compiler options [{type=ascascda}] specified"
    }
  },
  "status": 400
}

Here is my code sample

InlineScript.of(ib => ib.source(script).options(options).lang(ScriptLanguage.Painless))

Here is generated code that sent by client

{
  "script": {
    "lang": "painless",
    "source": """
       if (ctx._source['aaaaa'] != null) {
          if (!ctx._source['aaaaa'].contains(params)) {
            ctx._source['aaaaa'].add(params)
          }
        } else {
          ctx._source['aaaaa'] = [params]
        }
    """,
    "options": {
      "type": "ascascda"
    }
  }
}

Mistake.
Found params field in parent class builder