Skip to content

Latest commit

 

History

History
154 lines (128 loc) · 3.69 KB

search-application-render-query.asciidoc

File metadata and controls

154 lines (128 loc) · 3.69 KB

Render Search Application Query

Render Search Application Query
New API reference

For the most up-to-date API details, refer to {api-es}/group/endpoint-search_application[Search application APIs].

preview::[]

Given specified query parameters, generates an {es} query using the search template associated with the search application or a default template if none is specified. Unspecified template parameters will be assigned their default values (if applicable). Returns the specific {es} query that would be generated and executed by calling search application search.

{api-request-title}

POST _application/search_application/<name>/_render_query

{api-prereq-title}

Requires read privileges on the backing alias of the search application.

{api-request-body-title}

params

(Optional, map of strings to objects) Query parameters used to generate the {es} query from the search template associated with the search application. If a parameter used in the search template is not specified in params, the parameter’s default value will be used.

Note

The search application can be configured to validate search template parameters. See the dictionary parameter in the put search application API for more information.

{api-response-codes-title}

400

Invalid parameter passed to search template. Examples include:

  • Missing required parameter

  • Invalid parameter data type

  • Invalid parameter value

404

Search Application <name> does not exist.

{api-examples-title}

The following example generates a query for a search application called my-app that uses the search template from the text search example:

POST _application/search_application/my-app/_render_query
{
  "params": {
    "query_string": "my first query",
    "text_fields": [
      {"name": "title", "boost": 5},
      {"name": "description", "boost": 1}
    ]
  }
}

A sample response:

{
  "from": 0,
  "size": 10,
  "query": {
    "multi_match": {
      "query": "my first query",
      "fields": [
        "description^1.0",
        "title^5.0"
      ]
    }
  },
  "explain": false
}

In this case, the from, size, and explain parameters are not specified in the request, so the default values specified in the search template are used.