Create a new document in the index | Elasticsearch API documentation (original) (raw)
Dismiss highlight Show more
Path parameters
- The name of the data stream or index to target. If the target doesn't exist and matches the name or wildcard (
*
) pattern of an index template with adata_stream
definition, this request creates the data stream. If the target doesn't exist and doesn’t match a data stream template, this request creates the index. - A unique identifier for the document. To automatically generate a document ID, use the
POST /<target>/_doc/
request format.
Query parameters
- Only perform the operation if the document has this primary term.
- Only perform the operation if the document has this sequence number.
- True or false if to include the document source in the error message in case of parsing errors.
- Set to
create
to only index the document if it does not already exist (put if absent). If a document with the specified_id
already exists, the indexing operation will fail. The behavior is the same as using the<index>/_create
endpoint. If a document ID is specified, this paramater defaults toindex
. Otherwise, it defaults tocreate
. If the request targets a data stream, anop_type
ofcreate
is required.
Supported values include:index
: Overwrite any documents that already exist.create
: Only index documents that do not already exist.
Values areindex
orcreate
.
- The ID of the pipeline to use to preprocess incoming documents. If the index has a default ingest pipeline specified, setting the value to
_none
turns off the default ingest pipeline for this request. If a final pipeline is configured, it will always run regardless of the value of this parameter. - If
true
, Elasticsearch refreshes the affected shards to make this operation visible to search. Ifwait_for
, it waits for a refresh to make this operation visible to search. Iffalse
, it does nothing with refreshes.
Values aretrue
,false
, orwait_for
. - If
true
, the destination must be an index alias. - If
true
, the request's actions must target a data stream (existing or to be created). - A custom value that is used to route operations to a specific shard.
- The period the request waits for the following operations: automatic index creation, dynamic mapping updates, waiting for active shards. Elasticsearch waits for at least the specified timeout period before failing. The actual wait time could be longer, particularly when multiple waits occur.
This parameter is useful for situations where the primary shard assigned to perform the operation might not be available when the operation runs. Some reasons for this might be that the primary shard is currently recovering from a gateway or undergoing relocation. By default, the operation will wait on the primary shard to become available for at least 1 minute before failing and responding with an error. The actual wait time could be longer, particularly when multiple waits occur. - The explicit version number for concurrency control. It must be a non-negative long number.
- The version type.
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: Theexternal_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.force
: This option is deprecated because it can cause primary and replica shards to diverge.
Values areinternal
,external
,external_gte
, orforce
.
- The number of shard copies that must be active before proceeding with the operation. You can set it to
all
or any positive integer up to the total number of shards in the index (number_of_replicas+1
). The default value of1
means it waits for each primary shard to be active.
application/json
Body Required
Responses
- 200 application/json
Hide response attributes Show response attributes object- The primary term assigned to the document for the indexing operation.
- Values are
created
,updated
,deleted
,not_found
, ornoop
. - Hide _shards attributes Show _shards attributes object
* Hide failures attributes Show failures attributes object
* Hide reason attributes Show reason attributes object
* The type of error
* A human-readable explanation of the error, in English.
* The server stack trace. Present only if theerror_trace=true
parameter was sent with the request.