Core 2.x

mGet

Gets multiple documents.

The number of documents that can be fetched by a single request is limited by the documentsFetchCount server configuration (see the Configuring Kuzzle guide).


Query Syntax

HTTP

Copied to clipboard!
URL: http://kuzzle:7512/<index>/<collection>/_mGet
Method: POST
Body:
Copied to clipboard!
{
  "ids": ["<documentId>", "<anotherDocumentId>"]
}

You can also access this route with the GET verb:

Copied to clipboard!
URL: http://kuzzle:7512/<index>/<collection>/_mGet?ids=documentId,anotherDocumentId
Method: GET

Other protocols

Copied to clipboard!
{
  "index": "<index>",
  "collection": "<collection>",
  "controller": "document",
  "action": "mGet",
  "body": {
    "ids": ["<documentId>", "<anotherDocumentId>"]
  }
}

Arguments

  • collection: collection name
  • index: index name

Body properties

  • ids: an array of document identifiers to fetch

Response

Returns an object containing 2 arrays: successes and errors

The successes array contain the list of retrieved documents.

Each document is an object with the following properties:

  • _id: document unique identifier
  • _source: document content
  • _version: version number of the document

The errors array contain the IDs of not found documents.

Copied to clipboard!
{
  "status": 200,
  "error": null,
  "index": "<index>",
  "collection": "<collection>",
  "action": "mGet",
  "controller": "document",
  "requestId": "<unique request identifier>",
  "result": {
    "hits": [
      {
        "_id": "<documentId>",
        "_source": {
          // document content
        },
        "_version": 4
      },
      {
        "_id": "<anotherDocumentId>",
        "_source": {
          // document content
        },
        "_version": 2
      }
    ]
    "errors": ["<anotherDocumentId>"]
  }
}