search

edit
client.search({
  index: string | string[],
  type: string | string[],
  analyzer: string,
  analyze_wildcard: boolean,
  default_operator: 'AND' | 'OR',
  df: string,
  explain: boolean,
  stored_fields: string | string[],
  docvalue_fields: string | string[],
  from: number,
  ignore_unavailable: boolean,
  ignore_throttled: boolean,
  allow_no_indices: boolean,
  expand_wildcards: 'open' | 'closed' | 'none' | 'all',
  lenient: boolean,
  preference: string,
  q: string,
  routing: string | string[],
  scroll: string,
  search_type: 'query_then_fetch' | 'dfs_query_then_fetch',
  size: number,
  sort: string | string[],
  _source: string | string[],
  _source_excludes: string | string[],
  _source_includes: string | string[],
  terminate_after: number,
  stats: string | string[],
  suggest_field: string,
  suggest_mode: 'missing' | 'popular' | 'always',
  suggest_size: number,
  suggest_text: string,
  timeout: string,
  track_scores: boolean,
  track_total_hits: boolean,
  allow_partial_search_results: boolean,
  typed_keys: boolean,
  version: boolean,
  seq_no_primary_term: boolean,
  request_cache: boolean,
  batched_reduce_size: number,
  max_concurrent_shard_requests: number,
  pre_filter_shard_size: number,
  rest_total_hits_as_int: boolean,
  body: object
})

Reference

index

string | string[] - A comma-separated list of index names to search; use _all or empty string to perform the operation on all indices

type

string | string[] - A comma-separated list of document types to search; leave empty to perform the operation on all types

analyzer

string - The analyzer to use for the query string

analyze_wildcard or analyzeWildcard

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

default_operator or defaultOperator

'AND' | 'OR' - The default operator for query string query (AND or OR)
Default: OR

df

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

explain

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

stored_fields or storedFields

string | string[] - A comma-separated list of stored fields to return as part of a hit

docvalue_fields or docvalueFields

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

from

number - Starting offset (default: 0)

ignore_unavailable or ignoreUnavailable

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

ignore_throttled or ignoreThrottled

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

allow_no_indices or allowNoIndices

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

expand_wildcards or expandWildcards

'open' | 'closed' | 'none' | 'all' - Whether to expand wildcard expression to concrete indices that are open, closed or both.
Default: open

lenient

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

preference

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

q

string - Query in the Lucene query string syntax

routing

string | string[] - A comma-separated list of specific routing values

scroll

string - Specify how long a consistent view of the index should be maintained for scrolled search

search_type or searchType

'query_then_fetch' | 'dfs_query_then_fetch' - Search operation type

size

number - Number of hits to return (default: 10)

sort

string | string[] - A comma-separated list of <field>:<direction> pairs

_source

string | string[] - True or false to return the _source field or not, or a list of fields to return

_source_excludes or _sourceExcludes

string | string[] - A list of fields to exclude from the returned _source field

_source_includes or _sourceIncludes

string | string[] - A list of fields to extract and return from the _source field

terminate_after or terminateAfter

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

stats

string | string[] - Specific tag of the request for logging and statistical purposes

suggest_field or suggestField

string - Specify which field to use for suggestions

suggest_mode or suggestMode

'missing' | 'popular' | 'always' - Specify suggest mode
Default: missing

suggest_size or suggestSize

number - How many suggestions to return in response

suggest_text or suggestText

string - The source text for which the suggestions should be returned

timeout

string - Explicit operation timeout

track_scores or trackScores

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

track_total_hits or trackTotalHits

boolean - Indicate if the number of documents that match the query should be tracked

allow_partial_search_results or allowPartialSearchResults

boolean - Indicate if an error should be returned if there is a partial search failure or timeout
Default: true

typed_keys or typedKeys

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

version

boolean - Specify whether to return document version as part of a hit

seq_no_primary_term or seqNoPrimaryTerm

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

request_cache or requestCache

boolean - Specify if request cache should be used for this request or not, defaults to index level setting

batched_reduce_size or batchedReduceSize

number - The number of shard results that should be reduced at once on the coordinating node. This value should be used as a protection mechanism to reduce the memory overhead per search request if the potential number of shards in the request can be large.
Default: 512

max_concurrent_shard_requests or maxConcurrentShardRequests

number - The number of concurrent shard requests 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
Default: The default grows with the number of nodes in the cluster but is at most 256.

pre_filter_shard_size or preFilterShardSize

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 it’s rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint.
Default: 128

rest_total_hits_as_int or restTotalHitsAsInt

boolean - This parameter is ignored in this version. It is used in the next major version to control whether the rest response should render the total.hits as an object or a number

body

object - The search definition using the Query DSL