AuthThe Elastic Stack includes Elastic's core products such as Elasticsearch, Kibana, Logstash, and Beats.AvailabilityGenerally available since 1.3This functionality is generally available and ready for production usage.Unless stated otherwise on the page, this functionality is available when your Elastic Stack is deployed on Elastic Cloud Hosted, Elastic Cloud Enterprise, Elastic Cloud on Kubernetes, and self-managed environments.This documentation corresponds to the latest patch available for each minor version. If you're not using the latest patch, check the release notes for changes.
Get multiple JSON documents by ID from one or more indices.
If you specify an index in the request URI, you only need to specify the document IDs in the request body.
To ensure fast responses, this multi get (mget) API responds with partial results if one or more shards fail.
Filter source fields
By default, the _source field is returned for every document (if stored).
Use the _source and _source_include or source_exclude attributes to filter what fields are returned for a particular document.
You can include the _source, _source_includes, and _source_excludes query parameters in the request URI to specify the defaults to use when there are no per-document instructions.
Get stored fields
Use the stored_fields attribute to specify the set of stored fields you want to retrieve.
Any requested fields that are not stored are ignored.
You can include the stored_fields query parameter in the request URI to specify the defaults to use when there are no per-document instructions.
Specifies the node or shard the operation should be performed on. Random by default.
realtimeboolean · default: true
If true, the request is real-time as opposed to near-real-time.
refreshboolean · default: false
If true, the request refreshes relevant shards before retrieving documents.
routingunionstring | string[]
Custom value used to route operations to a specific shard.
Not allowed when index.slice.enabled is true for the target index; use _slice instead.
_sourceuniononeOf
True or false to return the _source field or not, or a list of fields to return.
One of:booleanorstring
_source_excludesunionstring | string[]
A comma-separated list of source fields to exclude from the response.
You can also use this parameter to exclude fields from the subset specified in _source_includes query parameter.
_source_includesunionstring | string[]
A comma-separated list of source fields to include in the response.
If this parameter is specified, only these source fields are returned. You can exclude fields from this subset using the _source_excludes query parameter.
If the _source parameter is false, this parameter is ignored.
stored_fieldsuniononeOf · default: false
If true, retrieves the document fields stored in the index rather than the document _source.
The documents you want to retrieve. Required if no index is specified in the request URI.
_idstringrequired
The unique document ID.
_indexstring
The index that contains the document.
routinguniononeOf
The key for the primary shard the document resides on. Required if routing is used during indexing.
Not allowed when index.slice.enabled is true for the target index; use _slice instead.
One of:string[]orstring
_sourceuniononeOf
If false, excludes all _source fields.
One of:
exclude_vectorsboolean
If true, vector fields are excluded from the returned source.
This option takes precedence over includes: any vector field will
remain excluded even if it matches an includes rule.
excludesuniononeOf
A list of fields to exclude from the returned source.
One of:string[]orstring
includesuniononeOf
A list of fields to include in the returned source.
One of:string[]orstring
stored_fieldsuniononeOf
The stored fields you want to retrieve.
One of:string[]orstring
versionnumber
version_typeenum
Supported values include:
internal: Use internal versioning that starts at 1 and increments with each update or delete.
external: Only index the document if the specified version is strictly higher than the version of the stored document or if there is no existing document.
external_gte: Only index the document if the specified version is equal or higher than the version of the stored document or if there is no existing document.
NOTE: The external_gte version type is meant for special use cases and should be used with care.
If used incorrectly, it can result in loss of data.
Values:internalexternalexternal_gte
idsuniononeOf
The IDs of the documents you want to retrieve. Allowed when the index is specified in the request URI.
The response includes a docs array that contains the documents in the order specified in the request.
The structure of the returned documents is similar to that returned by the get API.
If there is a failure getting a particular document, the error is included in place of the document.
One of:
_indexstringrequired
The name of the index the document belongs to.
fieldsmapstring to object
If the stored_fields parameter is set to true and found is true, it contains the document fields stored in the index.
_ignoredstring[]
foundbooleanrequired
Indicates whether the document exists.
_idstringrequired
The unique identifier for the document.
_primary_termnumber
The primary term assigned to the document for the indexing operation.
_routingstring
The explicit routing, if set.
_seq_nonumber
The sequence number assigned to the document for the indexing operation.
Sequence numbers are used to ensure an older version of a document doesn't overwrite a newer version.
_sourceobject
If found is true, it contains the document data formatted in JSON.
If the _source parameter is set to false or the stored_fields parameter is set to true, it is excluded.
_versionnumber
The document version, which is ncremented each time the document is updated.
errorobjectrequired
typestringrequired
The type of error
reasonunionstringnullable
A human-readable explanation of the error, in English.
One of:string
stack_tracestring
The server stack trace. Present only if the error_trace=true parameter was sent with the request.