Put Search Application

edit

This functionality is in technical preview and may be changed or removed in a future release. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features.

Creates or updates a Search Application.

Request

edit

PUT _application/search_application/<name>

Prerequisites

edit

Requires the manage_search_application cluster privilege. Also requires manage privileges on all indices that are added to the Search Application.

Path parameters

edit
create
(Optional, Boolean) If true, this request cannot replace or update existing Search Applications. Defaults to false.
<body>

(Required, object) Contains parameters for a search application:

Properties of <body> objects
indices
(Required, array of strings) The indices associated with this search application. All indices need to exist in order to be added to a search application.
template

(Optional, object) The search template associated with this search application. The search application’s template is only stored and accessible through the search application.

  • This search template must be a Mustache template.
  • The template must contain a Mustache script and script source.
  • The template may be modified with subsequent put search application requests.
  • If no template is specified when creating a search application, or if a template is removed from a search application, we use the query_string defined in the template examples as a default.
  • This template will be used by the search application search API to execute searches.

Response codes

edit
404
Search Application <name> does not exist.
409
Search Application <name> exists and create is true.

Examples

edit

The following example creates a new Search Application called my-app:

PUT _application/search_application/my-app?create
{
  "indices": [ "index1", "index2" ],
  "template": {
    "script": {
      "source": {
        "query": {
          "query_string": {
            "query": "{{query_string}}",
            "default_field": "{{default_field}}"
          }
        }
      },
      "params": {
        "query_string": "*",
        "default_field": "*"
      }
    }
  }
}

The following example creates or updates an existing Search Application called my-app:

PUT _application/search_application/my-app
{
  "indices": [ "index1", "index2", "index3" ],
  "template": {
    "script": {
      "source": {
        "query": {
          "query_string": {
            "query": "{{query_string}}",
            "default_field": "{{default_field}}"
          }
        }
      },
      "params": {
        "query_string": "*",
        "default_field": "*"
      }
    }
  }
}