---
type: api
title: Run a search
description: **All methods and paths for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/operation/operation-search
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/operation/operation-search
products:
  - Elasticsearch
---

# Run a search


Availability:

## Paths

- `POST` (also `GET`) `/{index}/_search`
- `POST` (also `GET`) `/_search`

- [Api key auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/authentication#apikeyauth)
- [Basic auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/authentication#basicauth)
- [Bearer auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/authentication#bearerauth)

#### Path Parameters

- `index` (union IndexName | [] IndexName) — optional, leave it out to use `/_search`
  A comma-separated list of data streams, indices, and aliases to search.
It supports wildcards (`*`).
To search all data streams and indices, omit this parameter or use `*` or `_all`.

## Description

Get search hits that match the query defined in the request.
You can provide search queries using the `q` query string parameter or the request body.
If both are specified, only the query parameter is used.

If the Elasticsearch security features are enabled, you must have the read index privilege for the target data stream, index, or alias. For cross-cluster search, refer to the documentation about configuring CCS privileges.
To search a point in time (PIT) for an alias, you must have the `read` index privilege for the alias's data streams or indices.

**Search slicing**

When paging through a large number of documents, it can be helpful to split the search into multiple slices to consume them independently with the `slice` and `pit` properties.
By default the splitting is done first on the shards, then locally on each shard.
The local splitting partitions the shard into contiguous ranges based on Lucene document IDs.

For instance if the number of shards is equal to 2 and you request 4 slices, the slices 0 and 2 are assigned to the first shard and the slices 1 and 3 are assigned to the second shard.

IMPORTANT: The same point-in-time ID should be used for all slices.
If different PIT IDs are used, slices can overlap and miss documents.
This situation can occur because the splitting criterion is based on Lucene document IDs, which are not stable across changes to the index.

## Required authorization

* Index privileges: `read`

[Read the reference documentation](https://www.elastic.co/guide/en/elasticsearch/reference/8.19/remote-clusters-cert.html#remote-clusters-privileges-ccs)

## Query String Parameters

- `allow_no_indices` (boolean · default: true)
  If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indices.
This behavior applies even if the request targets other open indices.
For example, a request targeting `foo*,bar*` returns an error if an index starts with `foo` but no index starts with `bar`.
- `allow_partial_search_results` (boolean · default: true)
  If `true` and there are shard request timeouts or shard failures, the request returns partial results.
If `false`, it returns an error with no partial results.

To override the default behavior, you can set the `search.default_allow_partial_results` cluster setting to `false`.
- `analyzer` (string)
  The analyzer to use for the query string.
This parameter can be used only when the `q` query string parameter is specified.
- `analyze_wildcard` (boolean · default: false)
  If `true`, wildcard and prefix queries are analyzed.
This parameter can be used only when the `q` query string parameter is specified.
- `batched_reduce_size` (number · default: 512)
  The number of shard results that should be reduced at once on the coordinating node.
If the potential number of shards in the request can be large, this value should be used as a protection mechanism to reduce the memory overhead per search request.
- `ccs_minimize_roundtrips` (boolean · default: true)
  If `true`, network round-trips between the coordinating node and the remote clusters are minimized when running cross-cluster search (CCS) requests.
- `default_operator` (enum Operator · default: or)
  The default operator for the query string query: `and` or `or`.
This parameter can be used only when the `q` query string parameter is specified.
  Values: `and`, `AND`, `or`, `OR`
- `df` (string)
  The field to use as a default when no field prefix is given in the query string.
This parameter can be used only when the `q` query string parameter is specified.
- `docvalue_fields` (union Fields)
  A comma-separated list of fields to return as the docvalue representation of a field for each hit.
  One of: `Field` or `Field[]`
- `expand_wildcards` (string ExpandWildcards · default: open)
  The type of index that wildcard patterns can match.
If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams.
It supports comma-separated values such as `open,hidden`.

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: `all`, `open`, `closed`, `hidden`, `none`
- `explain` (boolean · default: false)
  If `true`, the request returns detailed information about score computation as part of a hit.
- `ignore_throttled` (boolean · default: true) — deprecated
  If `true`, concrete, expanded or aliased indices will be ignored when frozen.
- `ignore_unavailable` (boolean · default: false)
  If `false`, the request returns an error if it targets a missing or closed index.
- `include_named_queries_score` (boolean · default: false)
  If `true`, the response includes the score contribution from any named queries.

This functionality reruns each named query on every hit in a search response.
Typically, this adds a small overhead to a request.
However, using computationally expensive named queries on a large number of hits may add significant overhead.
- `lenient` (boolean · default: false)
  If `true`, format-based query failures (such as providing text to a numeric field) in the query string will be ignored.
This parameter can be used only when the `q` query string parameter is specified.
- `max_concurrent_shard_requests` (number · default: 5)
  The number of concurrent shard requests per node that the search runs 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.
- `min_compatible_shard_node` (string)
  The minimum version of the node that can handle the request
Any handling node with a lower version will fail the request.
- `preference` (string)
  The nodes and shards used for the search.
By default, Elasticsearch selects from eligible nodes and shards using adaptive replica selection, accounting for allocation awareness.
Valid values are:

* `_only_local` to run the search only on shards on the local node;
* `_local` to, if possible, run the search on shards on the local node, or if not, select shards using the default method;
* `_only_nodes:<node-id>,<node-id>` to run the search on only the specified nodes IDs, where, if suitable shards exist on more than one selected node, use shards on those nodes using the default method, or if none of the specified nodes are available, select shards from any available node using the default method;
* `_prefer_nodes:<node-id>,<node-id>` to if possible, run the search on the specified nodes IDs, or if not, select shards using the default method;
* `_shards:<shard>,<shard>` to run the search only on the specified shards;
* `<custom-string>` (any string that does not start with `_`) to route searches with the same `<custom-string>` to the same shards in the same order.
- `pre_filter_shard_size` (number)
  A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold.
This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method (if date filters are mandatory to match but the shard bounds and the query are disjoint).
When unspecified, the pre-filter phase is executed if any of these conditions is met:

* The request targets more than 128 shards.
* The request targets one or more read-only index.
* The primary sort of the query targets an indexed field.
- `request_cache` (boolean)
  If `true`, the caching of search results is enabled for requests where `size` is `0`.
It defaults to index level settings.
- `routing` (string Routing)
  A custom value that is used to route operations to a specific shard.
- `scroll` (string Duration)
  The period to retain the search context for scrolling.
By default, this value cannot exceed `1d` (24 hours).
You can change this limit by using the `search.max_keep_alive` cluster-level setting.
- `search_type` (enum SearchType)
  Indicates how distributed term frequencies are calculated for relevance scoring.

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: `query_then_fetch`, `dfs_query_then_fetch`
- `stats` ([] string)
  Specific `tag` of the request for logging and statistical purposes.
- `stored_fields` (union Fields)
  A comma-separated list of stored fields to return as part of a hit.
If no fields are specified, no stored fields are included in the response.
If this field is specified, the `_source` parameter defaults to `false`.
You can pass `_source: true` to return both source fields and stored fields in the search response.
  One of: `Field` or `Field[]`
- `suggest_field` (string Field)
  The field to use for suggestions.
- `suggest_mode` (enum SuggestMode · default: missing)
  The suggest mode.
This parameter can be used only when the `suggest_field` and `suggest_text` query string parameters are specified.

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: `missing`, `popular`, `always`
- `suggest_size` (number)
  The number of suggestions to return.
This parameter can be used only when the `suggest_field` and `suggest_text` query string parameters are specified.
- `suggest_text` (string)
  The source text for which the suggestions should be returned.
This parameter can be used only when the `suggest_field` and `suggest_text` query string parameters are specified.
- `terminate_after` (number · default: 0)
  The 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.

IMPORTANT: Use with caution.
Elasticsearch applies this parameter to each shard handling the request.
When possible, let Elasticsearch perform early termination automatically.
Avoid specifying this parameter for requests that target data streams with backing indices across multiple data tiers.
If set to `0` (default), the query does not terminate early.
- `timeout` (string Duration)
  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.
It defaults to no timeout.
- `track_total_hits` (boolean | number · default: 10000)
  The 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.
- `track_scores` (boolean · default: false)
  If `true`, the request calculates and returns document scores, even if the scores are not used for sorting.
- `typed_keys` (boolean · default: false)
  If `true`, aggregation and suggester names are be prefixed by their respective types in the response.
- `rest_total_hits_as_int` (boolean · default: false)
  Indicates whether `hits.total` should be rendered as an integer or an object in the rest search response.
- `version` (boolean · default: false)
  If `true`, the request returns the document version as part of a hit.
- `_source` (SourceConfigParam · default: true)
  The source fields that are returned for matching documents.
These fields are returned in the `hits._source` property of the search response.
Valid values are:

* `true` to return the entire document source.
* `false` to not return the document source.
* `<string>` to return the source fields that are specified as a comma-separated list that supports wildcard (`*`) patterns.
- `_source_excludes` (union Fields)
  A comma-separated list of source fields to exclude from the response.
You can also use this parameter to exclude fields from the subset specified in `_source_includes` query parameter.
If the `_source` parameter is `false`, this parameter is ignored.
  One of: `Field` or `Field[]`
- `_source_includes` (union Fields)
  A comma-separated list of source fields to include in the response.
If this parameter is specified, only these source fields are returned.
You can exclude fields from this subset using the `_source_excludes` query parameter.
If the `_source` parameter is `false`, this parameter is ignored.
  One of: `Field` or `Field[]`
- `seq_no_primary_term` (boolean)
  If `true`, the request returns the sequence number and primary term of the last modification of each hit.
- `q` (string)
  A query in the Lucene query string syntax.
Query parameter searches do not support the full Elasticsearch Query DSL but are handy for testing.

IMPORTANT: This parameter overrides the query parameter in the request body.
If both parameters are specified, documents matching the query request body parameter are not returned.
- `size` (number · default: 10)
  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.
- `from` (number · default: 0)
  The starting document offset, which must be non-negative.
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.
- `sort` (union string | [] string)
  A comma-separated list of `<field>:<direction>` pairs.
  One of: `string` or `string[]`

## Request Body

`application/json`

- `aggregations` (map string to {} AggregationContainer) — optional
  Defines the aggregations that are run as part of the search request.
  See [AggregationContainer](https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/types/_types-aggregations-aggregationcontainer)
- `collapse` ({} FieldCollapse) — optional
  Collapses search results the values of the specified field.
  - `field` (string Field) — required
    The field to collapse the result set on
  - `inner_hits` (union oneOf) — optional
    The number of inner hits and their sort order
    `InnerHits` or `InnerHits[]`
    - `name` (string Name) — optional
      The name for the particular inner hit definition in the response.
Useful when a search request contains multiple inner hits.
    - `size` (number · default: 3) — optional
      The maximum number of hits to return per `inner_hits`.
    - `from` (number · default: 0) — optional
      Inner hit starting document offset.
    - `collapse` ({} FieldCollapse) — optional — recursive
      Same fields as `collapse`
    - `docvalue_fields` ([] FieldAndFormat) — optional
      - `field` (string Field) — required
        A wildcard pattern. The request returns values for field names matching this pattern.
      - `format` (string) — optional
        The format in which the values are returned.
      - `include_unmapped` (boolean) — optional
    - `explain` (boolean) — optional
    - `highlight` ({} Highlight) — optional
      - `type` (HighlighterType) — optional
        

Supported values include:
  - `plain`: The `plain` highlighter uses the standard Lucene highlighter
  - `fvh`: The fvh highlighter uses the Lucene Fast Vector highlighter.
  - `unified`: The unified highlighter uses the Lucene Unified Highlighter.
        Values: `plain`, `fvh`, `unified`
      - `boundary_chars` (string · default: .,!? \t\n) — optional
        A string that contains each boundary character.
      - `boundary_max_scan` (number · default: 20) — optional
        How far to scan for boundary characters.
      - `boundary_scanner` (enum BoundaryScanner) — optional
        Specifies how to break the highlighted fragments: chars, sentence, or word.
Only valid for the unified and fvh highlighters.
Defaults to `sentence` for the `unified` highlighter. Defaults to `chars` for the `fvh` highlighter.

Supported values include:
  - `chars`: Use the characters specified by `boundary_chars` as highlighting boundaries.
The `boundary_max_scan` setting controls how far to scan for boundary characters.
Only valid for the `fvh` highlighter.
  - `sentence`: Break highlighted fragments at the next sentence boundary, as determined by Java’s `BreakIterator`.
You can specify the locale to use with `boundary_scanner_locale`.
When used with the `unified` highlighter, the `sentence` scanner splits sentences bigger than `fragment_size` at the first word boundary next to fragment_size.
You can set `fragment_size` to `0` to never split any sentence.
  - `word`: Break highlighted fragments at the next word boundary, as determined by Java’s `BreakIterator`.
You can specify the locale to use with `boundary_scanner_locale`.
        Values: `chars`, `sentence`, `word`
      - `boundary_scanner_locale` (string · default: Locale.ROOT) — optional
        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_source` (boolean) — optional — deprecated
      - `fragmenter` (enum HighlighterFragmenter · default: span) — optional
        Specifies how text should be broken up in highlight snippets: `simple` or `span`.
Only valid for the `plain` highlighter.
        Values: `simple`, `span`
      - `fragment_size` (number · default: 100) — optional
        The size of the highlighted fragment in characters.
      - `highlight_filter` (boolean) — optional
      - `highlight_query` ({} QueryContainer) — optional
        Highlight matches for a query other than the search query.
This is especially useful if you use a rescore query because those are not taken into account by highlighting by default.
        See [QueryContainer](https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/types/_types-query_dsl-querycontainer)
      - `max_fragment_length` (number) — optional
      - `max_analyzed_offset` (number) — optional
        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.
      - `no_match_size` (number · default: 0) — optional
        The amount of text you want to return from the beginning of the field if there are no matching fragments to highlight.
      - `number_of_fragments` (number · default: 5) — optional
        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.
      - `options` (map string to object) — optional
      - `order` (enum HighlighterOrder · default: none) — optional
        Sorts highlighted fragments by score when set to `score`.
By default, fragments will be output in the order they appear in the field (order: `none`).
Setting this option to `score` will output the most relevant fragments first.
Each highlighter applies its own logic to compute relevancy scores.
        Values: `score`
      - `phrase_limit` (number · default: 256) — optional
        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_tags` ([] string) — optional
        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_tags` ([] string) — optional
        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.
      - `require_field_match` (boolean · default: true) — optional
        By default, only fields that contains a query match are highlighted.
Set to `false` to highlight all fields.
      - `tags_schema` (enum HighlighterTagsSchema) — optional
        Set to `styled` to use the built-in tag schema.
        Values: `styled`
      - `encoder` (enum HighlighterEncoder) — optional
        Values: `default`, `html`
      - `fields` (map string to HighlightField) — required
        Map values ({} HighlightField)
        - `type` (HighlighterType) — optional
          

Supported values include:
  - `plain`: The `plain` highlighter uses the standard Lucene highlighter
  - `fvh`: The fvh highlighter uses the Lucene Fast Vector highlighter.
  - `unified`: The unified highlighter uses the Lucene Unified Highlighter.
          Values: `plain`, `fvh`, `unified`
        - `boundary_chars` (string · default: .,!? \t\n) — optional
          A string that contains each boundary character.
        - `boundary_max_scan` (number · default: 20) — optional
          How far to scan for boundary characters.
        - `boundary_scanner` (enum BoundaryScanner) — optional
          Specifies how to break the highlighted fragments: chars, sentence, or word.
Only valid for the unified and fvh highlighters.
Defaults to `sentence` for the `unified` highlighter. Defaults to `chars` for the `fvh` highlighter.

Supported values include:
  - `chars`: Use the characters specified by `boundary_chars` as highlighting boundaries.
The `boundary_max_scan` setting controls how far to scan for boundary characters.
Only valid for the `fvh` highlighter.
  - `sentence`: Break highlighted fragments at the next sentence boundary, as determined by Java’s `BreakIterator`.
You can specify the locale to use with `boundary_scanner_locale`.
When used with the `unified` highlighter, the `sentence` scanner splits sentences bigger than `fragment_size` at the first word boundary next to fragment_size.
You can set `fragment_size` to `0` to never split any sentence.
  - `word`: Break highlighted fragments at the next word boundary, as determined by Java’s `BreakIterator`.
You can specify the locale to use with `boundary_scanner_locale`.
          Values: `chars`, `sentence`, `word`
        - `boundary_scanner_locale` (string · default: Locale.ROOT) — optional
          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_source` (boolean) — optional — deprecated
        - `fragmenter` (enum HighlighterFragmenter · default: span) — optional
          Specifies how text should be broken up in highlight snippets: `simple` or `span`.
Only valid for the `plain` highlighter.
          Values: `simple`, `span`
        - `fragment_size` (number · default: 100) — optional
          The size of the highlighted fragment in characters.
        - `highlight_filter` (boolean) — optional
        - `highlight_query` ({} QueryContainer) — optional
          Highlight matches for a query other than the search query.
This is especially useful if you use a rescore query because those are not taken into account by highlighting by default.
          See [QueryContainer](https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/types/_types-query_dsl-querycontainer)
        - `max_fragment_length` (number) — optional
        - `max_analyzed_offset` (number) — optional
          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.
        - `no_match_size` (number · default: 0) — optional
          The amount of text you want to return from the beginning of the field if there are no matching fragments to highlight.
        - `number_of_fragments` (number · default: 5) — optional
          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.
        - `options` (map string to object) — optional
        - `order` (enum HighlighterOrder · default: none) — optional
          Sorts highlighted fragments by score when set to `score`.
By default, fragments will be output in the order they appear in the field (order: `none`).
Setting this option to `score` will output the most relevant fragments first.
Each highlighter applies its own logic to compute relevancy scores.
          Values: `score`
        - `phrase_limit` (number · default: 256) — optional
          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_tags` ([] string) — optional
          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_tags` ([] string) — optional
          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.
        - `require_field_match` (boolean · default: true) — optional
          By default, only fields that contains a query match are highlighted.
Set to `false` to highlight all fields.
        - `tags_schema` (enum HighlighterTagsSchema) — optional
          Set to `styled` to use the built-in tag schema.
          Values: `styled`
        - `fragment_offset` (number) — optional
        - `matched_fields` (string Fields) — optional
    - `ignore_unmapped` (boolean) — optional
    - `script_fields` (map string to ScriptField) — optional
      Map values ({} ScriptField)
      - `script` (string Script) — required
      - `ignore_failure` (boolean) — optional
    - `seq_no_primary_term` (boolean) — optional
    - `fields` ([] string Field) — optional
    - `sort` (Sort) — optional
      How the inner hits should be sorted per `inner_hits`.
By default, inner hits are sorted by score.
    - `_source` (SourceConfig) — optional
    - `stored_fields` (string Fields) — optional
    - `track_scores` (boolean · default: false) — optional
    - `version` (boolean) — optional
  - `max_concurrent_group_searches` (number) — optional
    The number of concurrent requests allowed to retrieve the inner_hits per group
  - `collapse` ({} FieldCollapse) — optional — recursive
    Same fields as `collapse`
- `explain` (boolean · default: false) — optional
  If `true`, the request returns detailed information about score computation as part of a hit.
- `ext` (map string to object) — optional
  Configuration of search extensions defined by Elasticsearch plugins.
- `from` (number · default: 0) — optional
  The starting document offset, which must be non-negative.
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.
- `highlight` ({} Highlight) — optional
  Specifies the highlighter to use for retrieving highlighted snippets from one or more fields in your search results.
  Same fields as `highlight` in `inner_hits`
- `track_total_hits` (boolean | number · default: 10000) — optional
  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.
- `indices_boost` ([] string to number) — optional
  Boost the `_score` of documents from specified indices.
The boost value is the factor by which scores are multiplied.
A boost value greater than `1.0` increases the score.
A boost value between `0` and `1.0` decreases the score.
- `docvalue_fields` ([] FieldAndFormat) — optional
  An array of wildcard (`*`) field patterns.
The request returns doc values for field names matching these patterns in the `hits.fields` property of the response.
  - `field` (string Field) — required
    A wildcard pattern. The request returns values for field names matching this pattern.
  - `format` (string) — optional
    The format in which the values are returned.
  - `include_unmapped` (boolean) — optional
- `knn` (union oneOf) — optional
  The approximate kNN search to run.
  `KnnSearch` or `KnnSearch[]`
  - `field` (string Field) — required
    The name of the vector field to search against
  - `query_vector` (QueryVector) — optional
    The query vector
  - `query_vector_builder` ({} QueryVectorBuilder) — optional
    The query vector builder. You must provide a query_vector_builder or query_vector, but not both.
    - `text_embedding` ({} TextEmbedding) — optional
      - `model_id` (string) — optional
        Model ID is required for all dense_vector fields but
may be inferred for semantic_text fields
      - `model_text` (string) — required
  - `k` (number) — optional
    The final number of nearest neighbors to return as top hits
  - `num_candidates` (number) — optional
    The number of nearest neighbor candidates to consider per shard
  - `boost` (number) — optional
    Boost value to apply to kNN scores
  - `filter` (union oneOf) — optional
    Filters for the kNN search query
    One of: [`QueryContainer[]`](https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/types/_types-query_dsl-querycontainer) or [`QueryContainer`](https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/types/_types-query_dsl-querycontainer)
    See [QueryContainer](https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/types/_types-query_dsl-querycontainer)
  - `similarity` (number) — optional
    The minimum similarity for a vector to be considered a match
  - `inner_hits` ({} InnerHits) — optional
    If defined, each search hit will contain inner hits.
    - `name` (string Name) — optional
      The name for the particular inner hit definition in the response.
Useful when a search request contains multiple inner hits.
    - `size` (number · default: 3) — optional
      The maximum number of hits to return per `inner_hits`.
    - `from` (number · default: 0) — optional
      Inner hit starting document offset.
    - `collapse` ({} FieldCollapse) — optional
      - `field` (string Field) — required
        The field to collapse the result set on
      - `inner_hits` (union oneOf) — optional — recursive
        The number of inner hits and their sort order
        `InnerHits` or `InnerHits[]`
      - `max_concurrent_group_searches` (number) — optional
        The number of concurrent requests allowed to retrieve the inner_hits per group
      - `collapse` ({} FieldCollapse) — optional — recursive
        Same fields as `collapse` in `inner_hits`
    - `docvalue_fields` ([] FieldAndFormat) — optional
      - `field` (string Field) — required
        A wildcard pattern. The request returns values for field names matching this pattern.
      - `format` (string) — optional
        The format in which the values are returned.
      - `include_unmapped` (boolean) — optional
    - `explain` (boolean) — optional
    - `highlight` ({} Highlight) — optional
      Same fields as `highlight` in `inner_hits`
    - `ignore_unmapped` (boolean) — optional
    - `script_fields` (map string to ScriptField) — optional
      Map values ({} ScriptField)
      - `script` (string Script) — required
      - `ignore_failure` (boolean) — optional
    - `seq_no_primary_term` (boolean) — optional
    - `fields` ([] string Field) — optional
    - `sort` (Sort) — optional
      How the inner hits should be sorted per `inner_hits`.
By default, inner hits are sorted by score.
    - `_source` (SourceConfig) — optional
    - `stored_fields` (string Fields) — optional
    - `track_scores` (boolean · default: false) — optional
    - `version` (boolean) — optional
  - `rescore_vector` ({} RescoreVector) — optional
    Apply oversampling and rescoring to quantized vectors *
    - `oversample` (number) — required
      Applies the specified oversample factor to k on the approximate kNN search
  - `_name` (string) — optional
- `rank` ({} RankContainer) — optional
  The Reciprocal Rank Fusion (RRF) to use.
  - `rrf` ({} RrfRank) — optional
    The reciprocal rank fusion parameters
    - `rank_constant` (number) — optional
      How much influence documents in individual result sets per query have over the final ranked result set
    - `rank_window_size` (number) — optional
      Size of the individual result sets per query
- `min_score` (number) — optional
  The minimum `_score` for matching documents.
Documents with a lower `_score` are not included in search results and results collected by aggregations.
- `post_filter` ({} QueryContainer) — optional
  Use the `post_filter` parameter to filter search results.
The search hits are filtered after the aggregations are calculated.
A post filter has no impact on the aggregation results.
  See [QueryContainer](https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/types/_types-query_dsl-querycontainer)
- `profile` (boolean · default: false) — optional
  Set to `true` to return detailed timing information about the execution of individual components in a search request.
NOTE: This is a debugging tool and adds significant overhead to search execution.
- `query` ({} QueryContainer) — optional
  The search definition using the Query DSL.
  See [QueryContainer](https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/types/_types-query_dsl-querycontainer)
- `rescore` (union oneOf) — optional
  Can be used to improve precision by reordering just the top (for example 100 - 500) documents returned by the `query` and `post_filter` phases.
  `Rescore` or `Rescore[]`
  - `window_size` (number) — optional
  - `query` ({} RescoreQuery) — optional
    - `rescore_query` ({} QueryContainer) — required
      The query to use for rescoring.
This query is only run on the Top-K results returned by the `query` and `post_filter` phases.
      See [QueryContainer](https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/types/_types-query_dsl-querycontainer)
    - `query_weight` (number · default: 1) — optional
      Relative importance of the original query versus the rescore query.
    - `rescore_query_weight` (number · default: 1) — optional
      Relative importance of the rescore query versus the original query.
    - `score_mode` (enum ScoreMode · default: total) — optional
      Determines how scores are combined.

Supported values include:
  - `avg`: Average the original score and the rescore query score.
  - `max`: Take the max of original score and the rescore query score.
  - `min`: Take the min of the original score and the rescore query score.
  - `multiply`: Multiply the original score by the rescore query score.
Useful for `function` query rescores.
  - `total`: Add the original score and the rescore query score.
      Values: `avg`, `max`, `min`, `multiply`, `total`
  - `learning_to_rank` ({} LearningToRank) — optional
    - `model_id` (string) — required
      The unique identifier of the trained model uploaded to Elasticsearch
    - `params` (map string to object) — optional
      Named parameters to be passed to the query templates used for feature
- `retriever` ({} RetrieverContainer) — optional
  A retriever is a specification to describe top documents returned from a search.
A retriever replaces other elements of the search API that also return top documents such as `query` and `knn`.
  - `standard` ({} StandardRetriever) — optional
    A retriever that replaces the functionality of a traditional query.
    - `filter` (union oneOf) — optional
      Query to filter the documents that can match.
      One of: [`QueryContainer[]`](https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/types/_types-query_dsl-querycontainer) or [`QueryContainer`](https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/types/_types-query_dsl-querycontainer)
      See [QueryContainer](https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/types/_types-query_dsl-querycontainer)
    - `min_score` (number) — optional
      Minimum _score for matching documents. Documents with a lower _score are not included in the top documents.
    - `_name` (string) — optional
      Retriever name.
    - `query` ({} QueryContainer) — optional
      Defines a query to retrieve a set of top documents.
      See [QueryContainer](https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/types/_types-query_dsl-querycontainer)
    - `search_after` (SortResults) — optional
      Defines a search after object parameter used for pagination.
    - `terminate_after` (number) — optional
      Maximum number of documents to collect for each shard.
    - `sort` (Sort) — optional
      A sort object that that specifies the order of matching documents.
    - `collapse` ({} FieldCollapse) — optional
      Collapses the top documents by a specified key into a single top document per key.
      Same fields as `collapse`
  - `knn` ({} KnnRetriever) — optional
    A retriever that replaces the functionality  of a knn search.
    - `filter` (union oneOf) — optional
      Query to filter the documents that can match.
      One of: [`QueryContainer[]`](https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/types/_types-query_dsl-querycontainer) or [`QueryContainer`](https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/types/_types-query_dsl-querycontainer)
      See [QueryContainer](https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/types/_types-query_dsl-querycontainer)
    - `min_score` (number) — optional
      Minimum _score for matching documents. Documents with a lower _score are not included in the top documents.
    - `_name` (string) — optional
      Retriever name.
    - `field` (string) — required
      The name of the vector field to search against.
    - `query_vector` (QueryVector) — optional
      Query vector. Must have the same number of dimensions as the vector field you are searching against. You must provide a query_vector_builder or query_vector, but not both.
    - `query_vector_builder` ({} QueryVectorBuilder) — optional
      Defines a model to build a query vector.
      - `text_embedding` ({} TextEmbedding) — optional
        - `model_id` (string) — optional
          Model ID is required for all dense_vector fields but
may be inferred for semantic_text fields
        - `model_text` (string) — required
    - `k` (number) — required
      Number of nearest neighbors to return as top hits.
    - `num_candidates` (number) — optional
      Number of nearest neighbor candidates to consider per shard.
    - `similarity` (number) — optional
      The minimum similarity required for a document to be considered a match.
    - `rescore_vector` ({} RescoreVector) — optional
      Apply oversampling and rescoring to quantized vectors *
      - `oversample` (number) — required
        Applies the specified oversample factor to k on the approximate kNN search
  - `rrf` ({} RRFRetriever) — optional
    A retriever that produces top documents from reciprocal rank fusion (RRF).
    - `filter` (union oneOf) — optional
      Query to filter the documents that can match.
      One of: [`QueryContainer[]`](https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/types/_types-query_dsl-querycontainer) or [`QueryContainer`](https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/types/_types-query_dsl-querycontainer)
      See [QueryContainer](https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/types/_types-query_dsl-querycontainer)
    - `min_score` (number) — optional
      Minimum _score for matching documents. Documents with a lower _score are not included in the top documents.
    - `_name` (string) — optional
      Retriever name.
    - `retrievers` ([] RetrieverContainer) — required — recursive
      A list of child retrievers to specify which sets of returned top documents will have the RRF formula applied to them.
      Same fields as `retriever`
    - `rank_constant` (number) — optional
      This value determines how much influence documents in individual result sets per query have over the final ranked result set.
    - `rank_window_size` (number) — optional
      This value determines the size of the individual result sets per query.
    - `query` (string) — optional
    - `fields` ([] string) — optional
  - `text_similarity_reranker` ({} TextSimilarityReranker) — optional
    A retriever that reranks the top documents based on a reranking model using the InferenceAPI
    - `filter` (union oneOf) — optional
      Query to filter the documents that can match.
      One of: [`QueryContainer[]`](https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/types/_types-query_dsl-querycontainer) or [`QueryContainer`](https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/types/_types-query_dsl-querycontainer)
      See [QueryContainer](https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/types/_types-query_dsl-querycontainer)
    - `min_score` (number) — optional
      Minimum _score for matching documents. Documents with a lower _score are not included in the top documents.
    - `_name` (string) — optional
      Retriever name.
    - `retriever` ({} RetrieverContainer) — required — recursive
      The nested retriever which will produce the first-level results, that will later be used for reranking.
      Same fields as `retriever`
    - `rank_window_size` (number) — optional
      This value determines how many documents we will consider from the nested retriever.
    - `inference_id` (string) — optional
      Unique identifier of the inference endpoint created using the inference API.
    - `inference_text` (string) — required
      The text snippet used as the basis for similarity comparison
    - `field` (string) — required
      The document field to be used for text similarity comparisons. This field should contain the text that will be evaluated against the inference_text
  - `rule` ({} RuleRetriever) — optional
    A retriever that replaces the functionality of a rule query.
    - `filter` (union oneOf) — optional
      Query to filter the documents that can match.
      One of: [`QueryContainer[]`](https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/types/_types-query_dsl-querycontainer) or [`QueryContainer`](https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/types/_types-query_dsl-querycontainer)
      See [QueryContainer](https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/types/_types-query_dsl-querycontainer)
    - `min_score` (number) — optional
      Minimum _score for matching documents. Documents with a lower _score are not included in the top documents.
    - `_name` (string) — optional
      Retriever name.
    - `ruleset_ids` (union Id | [] Id) — required
      The ruleset IDs containing the rules this retriever is evaluating against.
    - `match_criteria` (object) — required
      The match criteria that will determine if a rule in the provided rulesets should be applied.
    - `retriever` ({} RetrieverContainer) — required — recursive
      The retriever whose results rules should be applied to.
      Same fields as `retriever`
    - `rank_window_size` (number) — optional
      This value determines the size of the individual result set.
  - `rescorer` ({} RescorerRetriever) — optional
    A retriever that re-scores only the results produced by its child retriever.
    - `filter` (union oneOf) — optional
      Query to filter the documents that can match.
      One of: [`QueryContainer[]`](https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/types/_types-query_dsl-querycontainer) or [`QueryContainer`](https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/types/_types-query_dsl-querycontainer)
      See [QueryContainer](https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/types/_types-query_dsl-querycontainer)
    - `min_score` (number) — optional
      Minimum _score for matching documents. Documents with a lower _score are not included in the top documents.
    - `_name` (string) — optional
      Retriever name.
    - `retriever` ({} RetrieverContainer) — required — recursive
      Inner retriever.
      Same fields as `retriever`
    - `rescore` (union oneOf) — required
      `Rescore` or `Rescore[]`
      - `window_size` (number) — optional
      - `query` ({} RescoreQuery) — optional
        - `rescore_query` ({} QueryContainer) — required
          The query to use for rescoring.
This query is only run on the Top-K results returned by the `query` and `post_filter` phases.
          See [QueryContainer](https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/types/_types-query_dsl-querycontainer)
        - `query_weight` (number · default: 1) — optional
          Relative importance of the original query versus the rescore query.
        - `rescore_query_weight` (number · default: 1) — optional
          Relative importance of the rescore query versus the original query.
        - `score_mode` (enum ScoreMode · default: total) — optional
          Determines how scores are combined.

Supported values include:
  - `avg`: Average the original score and the rescore query score.
  - `max`: Take the max of original score and the rescore query score.
  - `min`: Take the min of the original score and the rescore query score.
  - `multiply`: Multiply the original score by the rescore query score.
Useful for `function` query rescores.
  - `total`: Add the original score and the rescore query score.
          Values: `avg`, `max`, `min`, `multiply`, `total`
      - `learning_to_rank` ({} LearningToRank) — optional
        - `model_id` (string) — required
          The unique identifier of the trained model uploaded to Elasticsearch
        - `params` (map string to object) — optional
          Named parameters to be passed to the query templates used for feature
  - `linear` ({} LinearRetriever) — optional
    A retriever that supports the combination of different retrievers through a weighted linear combination.
    - `filter` (union oneOf) — optional
      Query to filter the documents that can match.
      One of: [`QueryContainer[]`](https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/types/_types-query_dsl-querycontainer) or [`QueryContainer`](https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/types/_types-query_dsl-querycontainer)
      See [QueryContainer](https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/types/_types-query_dsl-querycontainer)
    - `min_score` (number) — optional
      Minimum _score for matching documents. Documents with a lower _score are not included in the top documents.
    - `_name` (string) — optional
      Retriever name.
    - `retrievers` ([] InnerRetriever) — optional
      Inner retrievers.
      - `retriever` ({} RetrieverContainer) — required — recursive
        The nested retriever configuration.
        Same fields as `retriever`
      - `weight` (number · default: 1) — optional
        Weight multiplier for this retriever's contribution to the linear combination.
Must be non-negative.
      - `normalizer` (enum ScoreNormalizer · default: none) — optional
        Score normalizer to apply to this retriever's results before weighting.
Falls back to the top-level `normalizer` on the linear retriever if unset,
then to `none` (identity) if neither is set.
        Values: `none`, `minmax`, `l2_norm`
    - `rank_window_size` (number) — optional
    - `query` (string) — optional
    - `fields` ([] string) — optional
    - `normalizer` (enum ScoreNormalizer) — optional
      Values: `none`, `minmax`, `l2_norm`
  - `pinned` ({} PinnedRetriever) — optional
    A pinned retriever applies pinned documents to the underlying retriever.
This retriever will rewrite to a PinnedQueryBuilder.
    - `filter` (union oneOf) — optional
      Query to filter the documents that can match.
      One of: [`QueryContainer[]`](https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/types/_types-query_dsl-querycontainer) or [`QueryContainer`](https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/types/_types-query_dsl-querycontainer)
      See [QueryContainer](https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/types/_types-query_dsl-querycontainer)
    - `min_score` (number) — optional
      Minimum _score for matching documents. Documents with a lower _score are not included in the top documents.
    - `_name` (string) — optional
      Retriever name.
    - `retriever` ({} RetrieverContainer) — required — recursive
      Inner retriever.
      Same fields as `retriever`
    - `ids` ([] string) — optional
    - `docs` ([] SpecifiedDocument) — optional
      - `index` (string IndexName) — optional
      - `id` (string Id) — required
    - `rank_window_size` (number) — optional
- `script_fields` (map string to ScriptField) — optional
  Retrieve a script evaluation (based on different fields) for each hit.
  Map values ({} ScriptField)
  - `script` (string Script) — required
  - `ignore_failure` (boolean) — optional
- `search_after` (SortResults) — optional
  Used to retrieve the next page of hits using a set of sort values from the previous page.
- `size` (number · default: 10) — optional
  The number of hits to return, which must not be negative.
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` property.
- `slice` ({} SlicedScroll) — optional
  Split a scrolled search into multiple slices that can be consumed independently.
  - `field` (string Field) — optional
  - `id` (string Id) — required
  - `max` (number) — required
- `sort` (Sort) — optional
  A comma-separated list of <field>:<direction> pairs.
- `_source` (SourceConfig) — optional
  The source fields that are returned for matching documents.
These fields are returned in the `hits._source` property of the search response.
If the `stored_fields` property is specified, the `_source` property defaults to `false`.
Otherwise, it defaults to `true`.
- `fields` ([] FieldAndFormat) — optional
  An array of wildcard (`*`) field patterns.
The request returns values for field names matching these patterns in the `hits.fields` property of the response.
  - `field` (string Field) — required
    A wildcard pattern. The request returns values for field names matching this pattern.
  - `format` (string) — optional
    The format in which the values are returned.
  - `include_unmapped` (boolean) — optional
- `suggest` ({} Suggester) — optional
  Defines a suggester that provides similar looking terms based on a provided text.
  - `text` (string) — optional
    Global suggest text, to avoid repetition when the same text is used in several suggesters
- `terminate_after` (number · default: 0) — optional
  The 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.

IMPORTANT: Use with caution.
Elasticsearch applies this property to each shard handling the request.
When possible, let Elasticsearch perform early termination automatically.
Avoid specifying this property for requests that target data streams with backing indices across multiple data tiers.

If set to `0` (default), the query does not terminate early.
- `timeout` (string) — optional
  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.
- `track_scores` (boolean · default: false) — optional
  If `true`, calculate and return document scores, even if the scores are not used for sorting.
- `version` (boolean · default: false) — optional
  If `true`, the request returns the document version as part of a hit.
- `seq_no_primary_term` (boolean) — optional
  If `true`, the request returns sequence number and primary term of the last modification of each hit.
- `stored_fields` (string Fields) — optional
  A comma-separated list of stored fields to return as part of a hit.
If no fields are specified, no stored fields are included in the response.
If this field is specified, the `_source` property defaults to `false`.
You can pass `_source: true` to return both source fields and stored fields in the search response.
- `pit` ({} PointInTimeReference) — optional
  Limit the search to a point in time (PIT).
If you provide a PIT, you cannot specify an `<index>` in the request path.
  - `id` (string Id) — required
  - `keep_alive` (string Duration) — optional
- `runtime_mappings` (RuntimeFields) — optional
  One or more runtime fields in the search request.
These fields take precedence over mapped fields with the same name.
- `stats` ([] string) — optional
  The 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.

## Response

`application/json`

- `took` (number)
  The number of milliseconds it took Elasticsearch to run the request.
This value is calculated by measuring the time elapsed between receipt of a request on the coordinating node and the time at which the coordinating node is ready to send the response.
It includes:

* Communication time between the coordinating node and data nodes
* Time the request spends in the search thread pool, queued for execution
* Actual run time

It does not include:

* Time needed to send the request to Elasticsearch
* Time needed to serialize the JSON response
* Time needed to send the response to a client
- `timed_out` (boolean)
  If `true`, the request timed out before completion; returned results may be partial or empty.
- `_shards` ({} ShardStatistics)
  A count of shards used for the request.
  - `failed` (number uint)
    The number of shards the operation or search attempted to run on but failed.
  - `successful` (number uint)
    The number of shards the operation or search succeeded on.
  - `total` (number uint)
    The number of shards the operation or search will run on overall.
  - `failures` ([] ShardFailure)
    - `index` (string IndexName)
    - `node` (string)
    - `reason` ({} ErrorCause)
      - `type` (string)
        The type of error
      - `reason` (union string) — nullable
        A human-readable explanation of the error, in English.
        One of: `string`
      - `stack_trace` (string)
        The server stack trace. Present only if the `error_trace=true` parameter was sent with the request.
      - `caused_by` ({} ErrorCause) — recursive
        Same fields as `reason` in `failures`
      - `root_cause` ([] ErrorCause) — recursive
        Same fields as `reason` in `failures`
      - `suppressed` ([] ErrorCause) — recursive
        Same fields as `reason` in `failures`
    - `shard` (number)
    - `status` (string)
    - `primary` (boolean)
  - `skipped` (number uint)
- `hits` ({} HitsMetadata)
  The returned documents and metadata.
  - `total` (union oneOf)
    Total hit count information, present only if `track_total_hits` wasn't `false` in the search request.
    - **TotalHits**
      - `relation` (enum TotalHitsRelation)
        

Supported values include:
  - `eq`: Accurate
  - `gte`: Lower bound, including returned events or sequences
        Values: `eq`, `gte`
      - `value` (number)
    - **number**
  - `hits` ([] Hit)
    - `_index` (string IndexName)
    - `_id` (string Id)
    - `_score` (union number | string) — nullable
    - `_explanation` ({} Explanation)
      - `description` (string)
      - `details` ([] ExplanationDetail)
        - `description` (string)
        - `details` ([] ExplanationDetail) — recursive
          Same fields as `details` in `_explanation`
        - `value` (number)
      - `value` (number)
    - `fields` (map string to object)
    - `highlight` (map string to string)
    - `inner_hits` (map string to InnerHitsResult)
      Map values ({} InnerHitsResult)
      - `hits` ({} HitsMetadata) — recursive
        Same fields as `hits`
    - `matched_queries` (union oneOf)
      One of: `string[]` or `string to number`
    - `_nested` ({} NestedIdentity)
      - `field` (string Field)
      - `offset` (number)
      - `_nested` ({} NestedIdentity) — recursive
        Same fields as `_nested` in `hits`
    - `_ignored` ([] string)
    - `ignored_field_values` (map string to FieldValue)
    - `_shard` (string)
    - `_node` (string)
    - `_routing` (string)
    - `_source` (object)
    - `_rank` (number)
    - `_seq_no` (number SequenceNumber)
    - `_primary_term` (number)
    - `_version` (number VersionNumber)
    - `sort` (SortResults)
  - `max_score` (union number | string) — nullable
- `aggregations` (map string to {} Aggregate)
  See [Aggregate](https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/types/_types-aggregations-aggregate)
- `_clusters` ({} ClusterStatistics)
  - `skipped` (number)
  - `successful` (number)
  - `total` (number)
  - `running` (number)
  - `partial` (number)
  - `failed` (number)
  - `details` (map string to ClusterDetails)
    Map values ({} ClusterDetails)
    - `status` (enum ClusterSearchStatus)
      Values: `running`, `successful`, `partial`, `skipped`, `failed`
    - `indices` (string)
    - `took` (DurationValueUnitMillis)
    - `timed_out` (boolean)
    - `_shards` ({} ShardStatistics)
      Same fields as `_shards`
    - `failures` ([] ShardFailure)
      Same fields as `failures` in `_shards`
- `fields` (map string to object)
- `max_score` (number)
- `num_reduce_phases` (number)
- `profile` ({} Profile)
  - `shards` ([] ShardProfile)
    - `aggregations` ([] AggregationProfile)
      - `breakdown` ({} AggregationBreakdown)
        - `build_aggregation` (number)
        - `build_aggregation_count` (number)
        - `build_leaf_collector` (number)
        - `build_leaf_collector_count` (number)
        - `collect` (number)
        - `collect_count` (number)
        - `initialize` (number)
        - `initialize_count` (number)
        - `post_collection` (number)
        - `post_collection_count` (number)
        - `reduce` (number)
        - `reduce_count` (number)
      - `description` (string)
      - `time_in_nanos` (DurationValueUnitNanos)
      - `type` (string)
      - `debug` ({} AggregationProfileDebug)
        - `segments_with_multi_valued_ords` (number)
        - `collection_strategy` (string)
        - `segments_with_single_valued_ords` (number)
        - `total_buckets` (number)
        - `built_buckets` (number)
        - `result_strategy` (string)
        - `has_filter` (boolean)
        - `delegate` (string)
        - `delegate_debug` ({} AggregationProfileDebug) — recursive
          Same fields as `debug` in `aggregations`
        - `chars_fetched` (number)
        - `extract_count` (number)
        - `extract_ns` (number)
        - `values_fetched` (number)
        - `collect_analyzed_ns` (number)
        - `collect_analyzed_count` (number)
        - `surviving_buckets` (number)
        - `ordinals_collectors_used` (number)
        - `ordinals_collectors_overhead_too_high` (number)
        - `string_hashing_collectors_used` (number)
        - `numeric_collectors_used` (number)
        - `empty_collectors_used` (number)
        - `deferred_aggregators` ([] string)
        - `segments_with_doc_count_field` (number)
        - `segments_with_deleted_docs` (number)
        - `filters` ([] AggregationProfileDelegateDebugFilter)
          - `results_from_metadata` (number)
          - `query` (string)
          - `specialized_for` (string)
          - `segments_counted_in_constant_time` (number)
        - `segments_counted` (number)
        - `segments_collected` (number)
        - `map_reducer` (string)
        - `brute_force_used` (number)
        - `dynamic_pruning_attempted` (number)
        - `dynamic_pruning_used` (number)
        - `skipped_due_to_no_data` (number)
      - `children` ([] AggregationProfile) — recursive
        Same fields as `aggregations` in `shards`
    - `cluster` (string)
    - `dfs` ({} DfsProfile)
      - `statistics` ({} DfsStatisticsProfile)
        - `type` (string)
        - `description` (string)
        - `time` (string Duration)
        - `time_in_nanos` (DurationValueUnitNanos)
        - `breakdown` ({} DfsStatisticsBreakdown)
          - `collection_statistics` (number)
          - `collection_statistics_count` (number)
          - `create_weight` (number)
          - `create_weight_count` (number)
          - `rewrite` (number)
          - `rewrite_count` (number)
          - `term_statistics` (number)
          - `term_statistics_count` (number)
        - `debug` (map string to object)
        - `children` ([] DfsStatisticsProfile) — recursive
          Same fields as `statistics` in `dfs`
      - `knn` ([] DfsKnnProfile)
        - `vector_operations_count` (number)
        - `query` ([] KnnQueryProfileResult)
          - `type` (string)
          - `description` (string)
          - `time` (string Duration)
          - `time_in_nanos` (DurationValueUnitNanos)
          - `breakdown` ({} KnnQueryProfileBreakdown)
            - `advance` (number)
            - `advance_count` (number)
            - `build_scorer` (number)
            - `build_scorer_count` (number)
            - `compute_max_score` (number)
            - `compute_max_score_count` (number)
            - `count_weight` (number)
            - `count_weight_count` (number)
            - `create_weight` (number)
            - `create_weight_count` (number)
            - `match` (number)
            - `match_count` (number)
            - `next_doc` (number)
            - `next_doc_count` (number)
            - `score` (number)
            - `score_count` (number)
            - `set_min_competitive_score` (number)
            - `set_min_competitive_score_count` (number)
            - `shallow_advance` (number)
            - `shallow_advance_count` (number)
          - `debug` (map string to object)
          - `children` ([] KnnQueryProfileResult) — recursive
            Same fields as `query` in `knn`
        - `rewrite_time` (number)
        - `collector` ([] KnnCollectorResult)
          - `name` (string)
          - `reason` (string)
          - `time` (string Duration)
          - `time_in_nanos` (DurationValueUnitNanos)
          - `children` ([] KnnCollectorResult) — recursive
            Same fields as `collector` in `knn`
    - `fetch` ({} FetchProfile)
      - `type` (string)
      - `description` (string)
      - `time_in_nanos` (DurationValueUnitNanos)
      - `breakdown` ({} FetchProfileBreakdown)
        - `load_source` (number)
        - `load_source_count` (number)
        - `load_stored_fields` (number)
        - `load_stored_fields_count` (number)
        - `next_reader` (number)
        - `next_reader_count` (number)
        - `process_count` (number)
        - `process` (number)
      - `debug` ({} FetchProfileDebug)
        - `stored_fields` ([] string)
        - `fast_path` (number)
      - `children` ([] FetchProfile) — recursive
        Same fields as `fetch` in `shards`
    - `id` (string)
    - `index` (string IndexName)
    - `node_id` (string)
    - `searches` ([] SearchProfile)
      - `collector` ([] Collector)
        - `name` (string)
        - `reason` (string)
        - `time_in_nanos` (DurationValueUnitNanos)
        - `children` ([] Collector) — recursive
          Same fields as `collector` in `searches`
      - `query` ([] QueryProfile)
        - `breakdown` ({} QueryBreakdown)
          - `advance` (number)
          - `advance_count` (number)
          - `build_scorer` (number)
          - `build_scorer_count` (number)
          - `create_weight` (number)
          - `create_weight_count` (number)
          - `match` (number)
          - `match_count` (number)
          - `shallow_advance` (number)
          - `shallow_advance_count` (number)
          - `next_doc` (number)
          - `next_doc_count` (number)
          - `score` (number)
          - `score_count` (number)
          - `compute_max_score` (number)
          - `compute_max_score_count` (number)
          - `count_weight` (number)
          - `count_weight_count` (number)
          - `set_min_competitive_score` (number)
          - `set_min_competitive_score_count` (number)
        - `description` (string)
        - `time_in_nanos` (DurationValueUnitNanos)
        - `type` (string)
        - `children` ([] QueryProfile) — recursive
          Same fields as `query` in `searches`
      - `rewrite_time` (number)
    - `shard_id` (number)
- `pit_id` (string Id)
- `_scroll_id` (string ScrollId)
  The identifier for the search and its search context.
You can use this scroll ID with the scroll API to retrieve the next batch of search results for the request.
This property is returned only if the `scroll` query parameter is specified in the request.
- `suggest` (map string to Suggest)
- `terminated_early` (boolean)
## Code Examples

#### Console

```console
POST /my-index-000001/_search?from=40&size=20
{
  "query": {
    "term": {
      "user.id": "kimchy"
    }
  }
}
```

#### JavaScript

```javascript
const response = await client.search({
  index: "my-index-000001",
  from: 40,
  size: 20,
  query: {
    term: {
      "user.id": "kimchy",
    },
  },
});
```

#### Python

```python
resp = client.search(
    index="my-index-000001",
    from_="40",
    size="20",
    query={
        "term": {
            "user.id": "kimchy"
        }
    },
)
```

#### curl

```curl
curl -X POST "$ELASTICSEARCH_URL/my-index-000001/_search?from=40&size=20" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": {
      "term": {
        "user.id": "kimchy"
      }
    }
  }'
```

#### Java

```java
client.search(s -> s
    .from(40)
    .index("my-index-000001")
    .query(q -> q
        .term(t -> t
            .field("user.id")
            .value(FieldValue.of("kimchy"))
        )
    )
    .size(20)
,Void.class);
```

#### C#

```c#
var response = await client
    .SearchAsync<MyDocument>(d1 => d1
        .Indices(new[] { "my-index-000001" })
        .Query(d2 => d2
            .Term(d3 => d3
                .Field(x => x.User.Id)
                .Value("kimchy")
            )
        )
    );
```

#### PHP

```php
$resp = $client->search([
    "index" => "my-index-000001",
    "from" => "40",
    "size" => "20",
    "body" => [
        "query" => [
            "term" => [
                "user.id" => "kimchy",
            ],
        ],
    ],
]);
```

#### Ruby

```ruby
response = client.search(
  index: "my-index-000001",
  from: "40",
  size: "20",
  body: {
    "query": {
      "term": {
        "user.id": "kimchy"
      }
    }
  }
)
```

## Response Examples

#### Search response example1

An abbreviated response from `GET /my-index-000001/_search?from=40&size=20` with a simple term query.

```json
{
  "took": 5,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": {
      "value": 20,
      "relation": "eq"
    },
    "max_score": 1.3862942,
    "hits": [
      {
        "_index": "my-index-000001",
        "_id": "0",
        "_score": 1.3862942,
        "_source": {
          "@timestamp": "2099-11-15T14:12:12",
          "http": {
            "request": {
              "method": "get"
            },
            "response": {
              "status_code": 200,
              "bytes": 1070000
            },
            "version": "1.1"
          },
          "source": {
            "ip": "127.0.0.1"
          },
          "message": "GET /search HTTP/1.1 200 1070000",
          "user": {
            "id": "kimchy"
          }
        }
      }
    ]
  }
}
```

