Skip to content

Improve request structure for scripts and templates #11091

Closed
@colings86

Description

@colings86

Created from the discussion at #8393 (comment)

The ScriptParameterParser added in 1.5 was an effort to make the parsing of scripts in Elasticsearch consistent but did not go far enough. The way scripts are defined in requests is still not one consistent method across the codebase. We want scripts to be defined in an object containing the script, params, lang, and type. This will be defined in the request in the following way:

Inline Scripts:

...
"script": {
    "inline": "doc[foo] + 1",
    "lang": "groovy",
    "params": {
        ...
    }
}
...

File Scripts:

...
"script": {
    "file": "my_file_script",
    "lang": "groovy",
    "params": {
        ...
    }
}
...

Index Scripts:

...
"script": {
    "id": "my_indexed_script",
    "lang": "groovy",
    "params": {
        ...
    }
}
...

Inline scripts can also be specified using the following short form, but the language will be the default language and the params will be empty:

...
"script": "doc[foo] + 1"
...

We should have similar constructs for templates. Also, the script and template classes should be available in the Java API and should be able to parse and render (build) themselves in XContent as well as being able to be serialized between nodes.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions