Query parameters

  • Blocks and waits until the search is completed up to a certain timeout. When the async search completes within the timeout, the response won’t include the ID as the results are not stored in the cluster.

    Values are -1 or 0.

  • Specifies how long the async search needs to be available. Ongoing async searches and any saved search results are deleted after this period.

    Values are -1 or 0.

  • If true, results are stored for later retrieval when the search completes within the wait_for_completion_timeout.

  • Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)

  • Indicate if an error should be returned if there is a partial search failure or timeout

  • analyzerstring

    The analyzer to use for the query string

  • Specify whether wildcard and prefix queries should be analyzed (default: false)

  • Affects how often partial results become available, which happens whenever shard results are reduced. A partial reduction is performed every time the coordinating node has received a certain number of new shard responses (5 by default).

  • The default value is the only supported value.

  • The default operator for query string query (AND or OR)

    Values are and, AND, or, or OR.

  • dfstring

    The field to use as default where no field prefix is given in the query string

  • docvalue_fieldsstring | array[string]

    A comma-separated list of fields to return as the docvalue representation of a field for each hit

  • expand_wildcardsstring | array[string]

    Whether to expand wildcard expression to concrete indices that are open, closed or both.

    Supported values include:

    • all: Match any data stream or index, including hidden ones.
    • open: Match open, non-hidden indices. Also matches any non-hidden data stream.
    • closed: Match closed, non-hidden indices. Also matches any non-hidden data stream. Data streams cannot be closed.
    • hidden: Match hidden data streams and hidden indices. Must be combined with open, closed, or both.
    • none: Wildcard expressions are not accepted.

    Values are all, open, closed, hidden, or none.

  • explainboolean

    Specify whether to return detailed information about score computation as part of a hit

  • Whether specified concrete, expanded or aliased indices should be ignored when throttled

  • Whether specified concrete indices should be ignored when unavailable (missing or closed)

  • lenientboolean

    Specify whether format-based query failures (such as providing text to a numeric field) should be ignored

  • The number of concurrent shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests

  • Specify the node or shard the operation should be performed on (default: random)

  • Specify if request cache should be used for this request or not, defaults to true

  • routingstring

    A comma-separated list of specific routing values

  • Search operation type

    Supported values include:

    • query_then_fetch: Documents are scored using local term and document frequencies for the shard. This is usually faster but less accurate.
    • dfs_query_then_fetch: Documents are scored using global term and document frequencies across all shards. This is usually slower but more accurate.

    Values are query_then_fetch or dfs_query_then_fetch.

  • statsarray[string]

    Specific 'tag' of the request for logging and statistical purposes

  • stored_fieldsstring | array[string]

    A comma-separated list of stored fields to return as part of a hit

  • Specifies which field to use for suggestions.

  • Specify suggest mode

    Supported values include:

    • missing: Only generate suggestions for terms that are not in the shard.
    • popular: Only suggest terms that occur in more docs on the shard than the original term.
    • always: Suggest any matching suggestions based on terms in the suggest text.

    Values are missing, popular, or always.

  • How many suggestions to return in response

  • The source text for which the suggestions should be returned.

  • The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.

  • timeoutstring

    Explicit operation timeout

    Values are -1 or 0.

  • track_total_hitsboolean | number

    Indicate if the number of documents that match the query should be tracked. A number can also be specified, to accurately track the total hit count up to the number.

  • Whether to calculate and return scores even if they are not used for sorting

  • typed_keysboolean

    Specify whether aggregation and suggester names should be prefixed by their respective types in the response

  • Indicates whether hits.total should be rendered as an integer or an object in the rest search response

  • versionboolean

    Specify whether to return document version as part of a hit

  • _sourceboolean | string | array[string]

    True or false to return the _source field or not, or a list of fields to return

  • _source_excludesstring | array[string]

    A list of fields to exclude from the returned _source field

  • _source_includesstring | array[string]

    A list of fields to extract and return from the _source field

  • Specify whether to return sequence number and primary term of the last modification of each hit

  • qstring

    Query in the Lucene query string syntax

  • sizenumber

    Number of hits to return (default: 10)

  • fromnumber

    Starting offset (default: 0)

  • sortstring | array[string]

    A comma-separated list of : pairs

application/json

Body

  • collapseobject
    External documentation
  • explainboolean

    If true, returns detailed information about score computation as part of a hit.

  • extobject

    Configuration of search extensions defined by Elasticsearch plugins.

    Hide ext attribute Show ext attribute object
    • *object Additional properties
  • fromnumber

    Starting document offset. By default, you cannot page through more than 10,000 hits using the from and size parameters. To page through more hits, use the search_after parameter.

  • highlightobject
    Hide highlight attributes Show highlight attributes object
    • typestring

      Any of:

      Values are plain, fvh, or unified.

    • A string that contains each boundary character.

    • How far to scan for boundary characters.

    • Values are chars, sentence, or word.

    • Controls which locale is used to search for sentence and word boundaries. This parameter takes a form of a language tag, for example: "en-US", "fr-FR", "ja-JP".

    • force_sourceboolean Deprecated
    • Values are simple or span.

    • The size of the highlighted fragment in characters.

    • An Elasticsearch Query DSL (Domain Specific Language) object that defines a query.

      External documentation
    • If set to a non-negative value, highlighting stops at this defined maximum limit. The rest of the text is not processed, thus not highlighted and no error is returned The max_analyzed_offset query setting does not override the index.highlight.max_analyzed_offset setting, which prevails when it’s set to lower value than the query setting.

    • The amount of text you want to return from the beginning of the field if there are no matching fragments to highlight.

    • The maximum number of fragments to return. If the number of fragments is set to 0, no fragments are returned. Instead, the entire field contents are highlighted and returned. This can be handy when you need to highlight short texts such as a title or address, but fragmentation is not required. If number_of_fragments is 0, fragment_size is ignored.

    • optionsobject
      Hide options attribute Show options attribute object
      • *object Additional properties
    • orderstring

      Value is score.

    • Controls the number of matching phrases in a document that are considered. Prevents the fvh highlighter from analyzing too many phrases and consuming too much memory. When using matched_fields, phrase_limit phrases per matched field are considered. Raising the limit increases query time and consumes more memory. Only supported by the fvh highlighter.

    • post_tagsarray[string]

      Use in conjunction with pre_tags to define the HTML tags to use for the highlighted text. By default, highlighted text is wrapped in <em> and </em> tags.

    • pre_tagsarray[string]

      Use in conjunction with post_tags to define the HTML tags to use for the highlighted text. By default, highlighted text is wrapped in <em> and </em> tags.

    • By default, only fields that contains a query match are highlighted. Set to false to highlight all fields.

    • Value is styled.

    • encoderstring

      Values are default or html.

    • fieldsobject Required
  • track_total_hitsboolean | number

    Number of hits matching the query to count accurately. If true, the exact number of hits is returned at the cost of some performance. If false, the response does not include the total number of hits matching the query. Defaults to 10,000 hits.

  • indices_boostarray[object]

    Boosts the _score of documents from specified indices.

    Hide indices_boost attribute Show indices_boost attribute object
    • *number Additional properties
  • docvalue_fieldsarray[object]

    Array of wildcard (*) patterns. The request returns doc values for field names matching these patterns in the hits.fields property of the response.

    Hide docvalue_fields attributes Show docvalue_fields attributes object
    • fieldstring Required

      Path to field or array of paths. Some API's support wildcards in the path to select multiple fields.

    • formatstring

      The format in which the values are returned.

  • knnobject | array[object]

    Defines the approximate kNN search to run.

    One of:
    Hide attributes Show attributes object
    • fieldstring Required

      Path to field or array of paths. Some API's support wildcards in the path to select multiple fields.

    • query_vectorarray[number]
    • Hide query_vector_builder attribute Show query_vector_builder attribute object
    • knumber

      The final number of nearest neigrs to return as top hits

    • The number of nearest neigr candidates to consider per shard

    • boostnumber

      Boost value to apply to kNN scores

    • filterobject | array[object]

      Filters for the kNN search query

      One of:

      An Elasticsearch Query DSL (Domain Specific Language) object that defines a query.

      External documentation

      An Elasticsearch Query DSL (Domain Specific Language) object that defines a query.

      An Elasticsearch Query DSL (Domain Specific Language) object that defines a query.

      External documentation
    • The minimum similarity for a vector to be considered a match

    • Hide inner_hits attributes Show inner_hits attributes object
      • namestring
      • sizenumber

        The maximum number of hits to return per inner_hits.

      • fromnumber

        Inner hit starting document offset.

      • collapseobject
        External documentation
      • docvalue_fieldsarray[object]
        Hide docvalue_fields attributes Show docvalue_fields attributes object
        • fieldstring Required

          Path to field or array of paths. Some API's support wildcards in the path to select multiple fields.

        • formatstring

          The format in which the values are returned.

      • explainboolean
      • highlightobject
        Hide highlight attributes Show highlight attributes object
        • A string that contains each boundary character.

        • How far to scan for boundary characters.

        • Values are chars, sentence, or word.

        • Controls which locale is used to search for sentence and word boundaries. This parameter takes a form of a language tag, for example: "en-US", "fr-FR", "ja-JP".

        • force_sourceboolean Deprecated
        • Values are simple or span.

        • The size of the highlighted fragment in characters.

        • An Elasticsearch Query DSL (Domain Specific Language) object that defines a query.

        • If set to a non-negative value, highlighting stops at this defined maximum limit. The rest of the text is not processed, thus not highlighted and no error is returned The max_analyzed_offset query setting does not override the index.highlight.max_analyzed_offset setting, which prevails when it’s set to lower value than the query setting.

        • The amount of text you want to return from the beginning of the field if there are no matching fragments to highlight.

        • The maximum number of fragments to return. If the number of fragments is set to 0, no fragments are returned. Instead, the entire field contents are highlighted and returned. This can be handy when you need to highlight short texts such as a title or address, but fragmentation is not required. If number_of_fragments is 0, fragment_size is ignored.

        • optionsobject
        • orderstring

          Value is score.

        • Controls the number of matching phrases in a document that are considered. Prevents the fvh highlighter from analyzing too many phrases and consuming too much memory. When using matched_fields, phrase_limit phrases per matched field are considered. Raising the limit increases query time and consumes more memory. Only supported by the fvh highlighter.

        • post_tagsarray[string]

          Use in conjunction with pre_tags to define the HTML tags to use for the highlighted text. By default, highlighted text is wrapped in <em> and </em> tags.

        • pre_tagsarray[string]

          Use in conjunction with post_tags to define the HTML tags to use for the highlighted text. By default, highlighted text is wrapped in <em> and </em> tags.

        • By default, only fields that contains a query match are highlighted. Set to false to highlight all fields.

        • Value is styled.

        • encoderstring

          Values are default or html.

        • fieldsobject Required
      • Hide script_fields attribute Show script_fields attribute object
        • *object Additional properties
          Hide * attributes Show * attributes object
      • fieldsarray[string]

        Path to field or array of paths. Some API's support wildcards in the path to select multiple fields.

      • sortstring | object | array[string | object]

        One of:

        Path to field or array of paths. Some API's support wildcards in the path to select multiple fields.

      • _sourceboolean | object

        Defines how to fetch a source. Fetching can be disabled entirely, or the source can be filtered.

        One of:
      • stored_fieldsstring | array[string]
      • versionboolean
    • Hide rescore_vector attribute Show rescore_vector attribute object
      • oversamplenumber Required

        Applies the specified oversample factor to k on the approximate kNN search

  • min_scorenumber

    Minimum _score for matching documents. Documents with a lower _score are not included in the search results.

  • An Elasticsearch Query DSL (Domain Specific Language) object that defines a query.

    External documentation
  • profileboolean
  • queryobject

    An Elasticsearch Query DSL (Domain Specific Language) object that defines a query.

    External documentation
  • rescoreobject | array[object]

    One of:
    Hide attributes Show attributes object
    • queryobject
      Hide query attributes Show query attributes object
    • Hide learning_to_rank attributes Show learning_to_rank attributes object
      • model_idstring Required

        The unique identifier of the trained model uploaded to Elasticsearch

      • paramsobject

        Named parameters to be passed to the query templates used for feature

        Hide params attribute Show params attribute object
        • *object Additional properties
  • Retrieve a script evaluation (based on different fields) for each hit.

    Hide script_fields attribute Show script_fields attribute object
    • *object Additional properties
      Hide * attributes Show * attributes object
      • scriptobject Required
        Hide script attributes Show script attributes object
        • sourcestring

          The script source.

        • idstring
        • paramsobject

          Specifies any named parameters that are passed into the script as variables. Use parameters instead of hard-coded values to decrease compile time.

          Hide params attribute Show params attribute object
          • *object Additional properties
        • langstring

          Any of:

          Values are painless, expression, mustache, or java.

        • optionsobject
          Hide options attribute Show options attribute object
          • *string Additional properties
  • search_afterarray[number | string | boolean | null | object]

    A field value.

  • sizenumber

    The number of hits to return. By default, you cannot page through more than 10,000 hits using the from and size parameters. To page through more hits, use the search_after parameter.

  • sliceobject
    Hide slice attributes Show slice attributes object
    • fieldstring

      Path to field or array of paths. Some API's support wildcards in the path to select multiple fields.

    • idstring Required
    • maxnumber Required
  • sortstring | object | array[string | object]

    One of:

    Path to field or array of paths. Some API's support wildcards in the path to select multiple fields.

    One of:

    Path to field or array of paths. Some API's support wildcards in the path to select multiple fields.

  • _sourceboolean | object

    Defines how to fetch a source. Fetching can be disabled entirely, or the source can be filtered.

    One of:
  • fieldsarray[object]

    Array of wildcard (*) patterns. The request returns values for field names matching these patterns in the hits.fields property of the response.

    Hide fields attributes Show fields attributes object
    • fieldstring Required

      Path to field or array of paths. Some API's support wildcards in the path to select multiple fields.

    • formatstring

      The format in which the values are returned.

  • suggestobject
    Hide suggest attribute Show suggest attribute object
    • textstring

      Global suggest text, to avoid repetition when the same text is used in several suggesters

  • Maximum number of documents to collect for each shard. If a query reaches this limit, Elasticsearch terminates the query early. Elasticsearch collects documents before sorting. Defaults to 0, which does not terminate query execution early.

  • timeoutstring

    Specifies the period of time to wait for a response from each shard. If no response is received before the timeout expires, the request fails and returns an error. Defaults to no timeout.

  • If true, calculate and return document scores, even if the scores are not used for sorting.

  • versionboolean

    If true, returns document version as part of a hit.

  • If true, returns sequence number and primary term of the last modification of each hit. See Optimistic concurrency control.

  • stored_fieldsstring | array[string]
  • pitobject
    Hide pit attributes Show pit attributes object
    • idstring Required
    • A duration. Units can be nanos, micros, ms (milliseconds), s (seconds), m (minutes), h (hours) and d (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.

  • Hide runtime_mappings attribute Show runtime_mappings attribute object
    • *object Additional properties
      Hide * attributes Show * attributes object
      • fieldsobject

        For type composite

        Hide fields attribute Show fields attribute object
        • *object Additional properties
          Hide * attribute Show * attribute object
          • typestring Required

            Values are boolean, composite, date, double, geo_point, geo_shape, ip, keyword, long, or lookup.

      • fetch_fieldsarray[object]

        For type lookup

        Hide fetch_fields attributes Show fetch_fields attributes object
        • fieldstring Required

          Path to field or array of paths. Some API's support wildcards in the path to select multiple fields.

        • formatstring
      • formatstring

        A custom format for date type runtime fields.

      • Path to field or array of paths. Some API's support wildcards in the path to select multiple fields.

      • Path to field or array of paths. Some API's support wildcards in the path to select multiple fields.

      • scriptobject
        Hide script attributes Show script attributes object
        • sourcestring

          The script source.

        • idstring
        • paramsobject

          Specifies any named parameters that are passed into the script as variables. Use parameters instead of hard-coded values to decrease compile time.

          Hide params attribute Show params attribute object
          • *object Additional properties
        • langstring

          Any of:

          Values are painless, expression, mustache, or java.

        • optionsobject
          Hide options attribute Show options attribute object
          • *string Additional properties
      • typestring Required

        Values are boolean, composite, date, double, geo_point, geo_shape, ip, keyword, long, or lookup.

  • statsarray[string]

    Stats groups to associate with the search. Each group maintains a statistics aggregation for its associated searches. You can retrieve these stats using the indices stats API.

Responses

  • 200 application/json
    Hide response attributes Show response attributes object
    • idstring
    • is_partialboolean Required

      When the query is no longer running, this property indicates whether the search failed or was successfully completed on all shards. While the query is running, is_partial is always set to true.

    • is_runningboolean Required

      Indicates whether the search is still running or has completed.


      If the search failed after some shards returned their results or the node that is coordinating the async search dies, results may be partial even though is_running is false.

    • expiration_timestring | number

      A date and time, either as a string whose format can depend on the context (defaulting to ISO 8601), or a number of milliseconds since the Epoch. Elasticsearch accepts both as input, but will generally output a string representation.

      One of:

      Time unit for milliseconds

    • Time unit for milliseconds

    • start_timestring | number

      A date and time, either as a string whose format can depend on the context (defaulting to ISO 8601), or a number of milliseconds since the Epoch. Elasticsearch accepts both as input, but will generally output a string representation.

      One of:

      Time unit for milliseconds

    • Time unit for milliseconds

    • completion_timestring | number

      A date and time, either as a string whose format can depend on the context (defaulting to ISO 8601), or a number of milliseconds since the Epoch. Elasticsearch accepts both as input, but will generally output a string representation.

      One of:

      Time unit for milliseconds

    • Time unit for milliseconds

    • responseobject Required
      Hide response attributes Show response attributes object
POST /_async_search
curl \
 --request POST 'http://api.example.com/_async_search' \
 --header "Authorization: $API_KEY" \
 --header "Content-Type: application/json" \
 --data '"{\n  \"sort\": [\n    { \"date\": { \"order\": \"asc\" } }\n  ],\n  \"aggs\": {\n    \"sale_date\": {\n      \"date_histogram\": {\n        \"field\": \"date\",\n        \"calendar_interval\": \"1d\"\n      }\n    }\n  }\n}"'
Request example
Perform a search request asynchronously with `POST /sales*/_async_search?size=0`. It accepts the same parameters and request body as the search API.
{
  "sort": [
    { "date": { "order": "asc" } }
  ],
  "aggs": {
    "sale_date": {
      "date_histogram": {
        "field": "date",
        "calendar_interval": "1d"
      }
    }
  }
}
Response examples (200)
A successful response when performing search asynchronously.
{
  "id" : "FmRldE8zREVEUzA2ZVpUeGs2ejJFUFEaMkZ5QTVrSTZSaVN3WlNFVmtlWHJsdzoxMDc=",
  "is_partial" : true,
  "is_running" : true,
  "start_time_in_millis" : 1583945890986,
  "expiration_time_in_millis" : 1584377890986,
  "response" : {
    "took" : 1122,
    "timed_out" : false,
    "num_reduce_phases" : 0,
    "_shards" : {
      "total" : 562,
      "successful" : 3,
      "skipped" : 0,
      "failed" : 0
    },
    "hits" : {
      "total" : {
        "value" : 157483,
        "relation" : "gte"
      },
      "max_score" : null,
      "hits" : [ ]
    }
  }
}