Get a script or search template Generally available

GET /_scripts/{id}

Retrieves a stored script or search template.

Required authorization

  • Cluster privileges: manage

Path parameters

  • id string Required

    The identifier for the stored script or search template.

Query parameters

  • master_timeout string

    The period to wait for the master node. If the master node is not available before the timeout expires, the request fails and returns an error. It can also be set to -1 to indicate that the request should never timeout.

    Values are -1 or 0.

Responses

  • 200 application/json
    Hide response attributes Show response attributes object
    • _id string Required
    • found boolean Required
    • script object
      Hide script attributes Show script attributes object
      • lang string

        The language the script is written in. For search templates, use mustache.

        Supported values include:

        • painless: Painless scripting language, purpose-built for Elasticsearch.
        • expression: Lucene’s expressions language, compiles a JavaScript expression to bytecode.
        • mustache: Mustache templated, used for templates.
        • java: Expert Java API
        Any of:

        The language the script is written in. For search templates, use mustache.

        Supported values include:

        • painless: Painless scripting language, purpose-built for Elasticsearch.
        • expression: Lucene’s expressions language, compiles a JavaScript expression to bytecode.
        • mustache: Mustache templated, used for templates.
        • java: Expert Java API

        Values are painless, expression, mustache, or java.

        The language the script is written in. For search templates, use mustache.

        Supported values include:

        • painless: Painless scripting language, purpose-built for Elasticsearch.
        • expression: Lucene’s expressions language, compiles a JavaScript expression to bytecode.
        • mustache: Mustache templated, used for templates.
        • java: Expert Java API
      • options object
        Hide options attribute Show options attribute object
        • * string Additional properties
      • source string | object

        The script source. For search templates, an object containing the search template.

        One of:

        The script source. For search templates, an object containing the search template.

GET _scripts/my-search-template
resp = client.get_script(
    id="my-search-template",
)
const response = await client.getScript({
  id: "my-search-template",
});
response = client.get_script(
  id: "my-search-template"
)
$resp = $client->getScript([
    "id" => "my-search-template",
]);
curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_scripts/my-search-template"
client.getScript(g -> g
    .id("my-search-template")
);