msearch

edit
client.msearch([params, [callback]])

Execute several search requests within the same request.

Check the API Conventions and the elasticsearch docs for more information pertaining to this method.

Perform multiple different searches, the body is made up of meta/data pairs.

const response = await client.msearch({
  body: [
    // match all query, on all indices and types
    {},
    { query: { match_all: {} } },

    // query_string query, on index/mytype
    { index: 'myindex', type: 'mytype' },
    { query: { query_string: { query: '"Test 1"' } } }
  ]
});

Params

searchType

String — Search operation type

Options
  • "query_then_fetch"
  • "query_and_fetch"
  • "dfs_query_then_fetch"
  • "dfs_query_and_fetch"

maxConcurrentSearches

Number — Controls the maximum number of concurrent searches the multi search api will execute

typedKeys

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

[preFilterShardSize=128]

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.

index

String, String[], Boolean — A comma-separated list of index names to use as default

type

String, String[], Boolean — A comma-separated list of document types to use as default

body

Object[], JSONLines — The request body, as either an array of objects or new-line delimited JSON objects. See the elasticsearch docs for details about what can be specified here.

back to top