Search Application Search

New API reference

For the most up-to-date API details, refer to Search application APIs.

This functionality is in beta and is subject to change. The design and code is less mature than official GA features and is being provided as-is with no warranties. Beta features are not subject to the support SLA of official GA features.

Given specified query parameters, generates and executes an Elasticsearch 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).

Request

POST _application/search_application/<name>/_search

Prerequisites

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

Path parameters

typed_keys

(Optional, Boolean) If true, aggregation and suggester names are prefixed by their respective types in the response. Defaults to false.

Request body

params

(Optional, map of strings to objects) Query parameters used to generate the Elasticsearch 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.

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

Response codes

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.

Examples

The following example executes a search against a search application called my-app that uses the search template from the text search example:

  1. resp = client.search_application.search(
  2. name="my-app",
  3. params={
  4. "query_string": "my first query",
  5. "text_fields": [
  6. {
  7. "name": "title",
  8. "boost": 5
  9. },
  10. {
  11. "name": "description",
  12. "boost": 1
  13. }
  14. ]
  15. },
  16. )
  17. print(resp)
  1. const response = await client.searchApplication.search({
  2. name: "my-app",
  3. params: {
  4. query_string: "my first query",
  5. text_fields: [
  6. {
  7. name: "title",
  8. boost: 5,
  9. },
  10. {
  11. name: "description",
  12. boost: 1,
  13. },
  14. ],
  15. },
  16. });
  17. console.log(response);
  1. POST _application/search_application/my-app/_search
  2. {
  3. "params": {
  4. "query_string": "my first query",
  5. "text_fields": [
  6. {"name": "title", "boost": 5},
  7. {"name": "description", "boost": 1}
  8. ]
  9. }
  10. }

The generated Elasticsearch query would look like:

  1. {
  2. "from": 0,
  3. "size": 10,
  4. "query": {
  5. "multi_match": {
  6. "query": "my first query",
  7. "fields": [
  8. "description^1.0",
  9. "title^5.0"
  10. ]
  11. }
  12. },
  13. "explain": false
  14. }

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.

The expected response is the search results from the Elasticsearch query that was generated & executed. The response format is the same as that used by the Elasticsearch Search API:

  1. {
  2. "took": 5,
  3. "timed_out": false,
  4. "_shards": {
  5. "total": 1,
  6. "successful": 1,
  7. "skipped": 0,
  8. "failed": 0
  9. },
  10. "hits": {
  11. "total": {
  12. "value": 1,
  13. "relation": "eq"
  14. },
  15. "max_score": 0.8630463,
  16. "hits": ...
  17. }
  18. }