Skip to content

Better handling of inline scripts in ingest #23824

@clintongormley

Description

@clintongormley

Anywhere that scripts are used, we allow writing an inline script in a short form, eg:

{ "script": {
    "lang": "painless",
    "inline": "ctx.foo='bar'
}}

can also be written as:

{ "script": "ctx.foo='bar'"}

If I try this in ingest:

POST _ingest/pipeline/_simulate
{
  "pipeline": {
    "processors": [
      {
        "script": "ctx.foo='bar'"
      }
    ]
  },
  "docs": [
    {
      "_index": "t",
      "_type": "t",
      "_id": "1",
      "_source": {}
    }
  ]
}

I get:

     {
        "type": "class_cast_exception",
        "reason": "java.lang.String cannot be cast to java.util.Map"
      }

While I understand that all processors expect an object and so the short form may not be supported (although it'd be nice to make an exception for scripts), we should at least have an exception which is easier to understand.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions