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"' } } }



String — Search operation type

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


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


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


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.


Number — The number of concurrent shard requests each sub search executes concurrently per node. 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


Boolean — Indicates whether should be rendered as an integer or an object in the rest search response


Boolean — Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution


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


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


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