client.mget([params, [callback]])

Get multiple documents based on an index, type (optional) and ids. The body required by mget can take two forms: an array of document locations, or an array of document ids.

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

An array of doc locations. Useful for getting documents from different indices.

const response = await client.mget({
  body: {
    docs: [
      { _index: 'indexA', _type: 'typeA', _id: '1' },
      { _index: 'indexB', _type: 'typeB', _id: '1' },
      { _index: 'indexC', _type: 'typeC', _id: '1' }

An array of ids. You must also specify the index and type that apply to all of the ids.

const response = await client.mget({
  index: 'myindex',
  type: 'mytype',
  body: {
    ids: [1, 2, 3]



String, String[], Boolean — A comma-separated list of stored fields to return in the response


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


Boolean — Specify whether to perform the operation in realtime or search mode


Boolean — Refresh the shard containing the document before performing the operation


String — Specific routing value


String, String[], Boolean — True or false to return the _source field or not, or a list of fields to return


String, String[], Boolean — A list of fields to exclude from the returned _source field


String, String[], Boolean — A list of fields to extract and return from the _source field


String — The name of the index


String — The type of the document


Object, JSON — The request body, as either JSON or a JSON serializable object. See the elasticsearch docs for details about what can be specified here.

back to top