Search + K

Command Palette

Search for a command to run...

Sign In

Get a document's source

GET /{index}/_source/{id}
Copy endpoint

Get the source of a document. For example:

GET my-index-000001/_source/1

You can use the source filtering parameters to control which parts of the _source are returned:

GET my-index-000001/_source/1/?_source_includes=*.id&_source_excludes=entities

Required authorization

  • Index privileges: read

Parameters

path Path Parameters

Name Type
index required

The name of the index that contains the document.

type TypesIndexName = string
id required

A unique document identifier.

type TypesId = string

query Query Parameters

Name Type
preference

The node or shard the operation should be performed on. By default, the operation is randomized between the shard replicas.

string
realtime

If true, the request is real-time as opposed to near-real-time.

boolean
refresh

If true, the request refreshes the relevant shards before retrieving the document. Setting it to true should be done after careful thought and verification that this does not cause a heavy load on the system (and slow down indexing).

boolean
routing

A custom value used to route operations to a specific shard.

type TypesRouting = string[] | string
_source

Indicates whether to return the _source field (true or false) or lists the fields to return.

type GlobalSearchTypesSourceConfigParam = type TypesFields = type TypesField = string | type TypesField = string[] | boolean
_source_excludes

A comma-separated list of source fields to exclude in the response.

type TypesFields = type TypesField = string | type TypesField = string[]
_source_includes

A comma-separated list of source fields to include in the response.

type TypesFields = type TypesField = string | type TypesField = string[]
version

The version number for concurrency control. It must match the current version of the document for the request to succeed.

type TypesVersionNumber = number
version_type

The version type.

type TypesVersionType = "internal" | "external" | "external_gte"

Responses

200 application/json
{}