[DOCS] Add data streams to bulk, delete, and index API docs (#58340) (#58434)

Updates existing docs for the bulk, delete and index APIs to make them
aware of data streams.
This commit is contained in:
James Rodewig 2020-06-23 09:40:25 -04:00 committed by GitHub
parent 8ebd341710
commit afbf3bd33b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 65 additions and 26 deletions

View File

@ -24,7 +24,7 @@ POST _bulk
`POST /_bulk` `POST /_bulk`
`POST /<index>/_bulk` `POST /<target>/_bulk`
[[docs-bulk-api-desc]] [[docs-bulk-api-desc]]
==== {api-description-title} ==== {api-description-title}
@ -47,8 +47,12 @@ optional_source\n
The `index` and `create` actions expect a source on the next line, The `index` and `create` actions expect a source on the next line,
and have the same semantics as the `op_type` parameter in the standard index API: and have the same semantics as the `op_type` parameter in the standard index API:
create fails if a document with the same name already exists in the index, `create` fails if a document with the same ID already exists in the target,
index adds or replaces a document as necessary. `index` adds or replaces a document as necessary.
NOTE: <<data-streams,Data streams>> support only the `create` action. To update
or delete a document in a data stream, you must target the backing index
containing the document. See <<update-delete-docs-in-a-data-stream>>.
`update` expects that the partial doc, upsert, `update` expects that the partial doc, upsert,
and script and its options are specified on the next line. and script and its options are specified on the next line.
@ -67,8 +71,8 @@ the `Content-Type` header should be set to `application/x-ndjson`.
Because this format uses literal `\n`'s as delimiters, Because this format uses literal `\n`'s as delimiters,
make sure that the JSON actions and sources are not pretty printed. make sure that the JSON actions and sources are not pretty printed.
If you specify an index in the request URI, If you provide a `<target>` in the request path,
it is used for any actions that don't explicitly specify an index. it is used for any actions that don't explicitly specify an `_index` argument.
A note on the format: The idea here is to make processing of this as A note on the format: The idea here is to make processing of this as
fast as possible. As some of the actions are redirected to other fast as possible. As some of the actions are redirected to other
@ -192,8 +196,10 @@ See <<url-access-control>>.
[[docs-bulk-api-path-params]] [[docs-bulk-api-path-params]]
==== {api-path-parms-title} ==== {api-path-parms-title}
`<index>`:: `<target>`::
(Optional, string) Name of the index to perform the bulk actions against. (Optional, string)
Name of the data stream, index, or index alias to perform bulk actions
on.
[[docs-bulk-api-query-params]] [[docs-bulk-api-query-params]]
==== {api-query-parms-title} ==== {api-query-parms-title}
@ -321,7 +327,8 @@ operation.
===== =====
`_index`:: `_index`::
(string) (string)
The index name or alias associated with the operation. Name of the index associated with the operation. If the operation targeted a
data stream, this is the backing index into which the document was written.
`_type`:: `_type`::
(string) (string)
@ -415,7 +422,9 @@ ID of the shard associated with the failed operation.
`index`:: `index`::
(string) (string)
The index name or alias associated with the failed operation. Name of the index associated with the failed operation. If the operation
targeted a data stream, this is the backing index into which the document was
attempted to be written.
====== ======
===== =====
==== ====

View File

@ -17,6 +17,10 @@ Removes a JSON document from the specified index.
You use DELETE to remove a document from an index. You must specify the You use DELETE to remove a document from an index. You must specify the
index name and document ID. index name and document ID.
NOTE: You cannot send deletion requests directly to a data stream. To delete a
document in a data stream, you must target the backing index containing the
document. See <<update-delete-docs-in-a-data-stream>>.
[float] [float]
[[optimistic-concurrency-control-delete]] [[optimistic-concurrency-control-delete]]
===== Optimistic concurrency control ===== Optimistic concurrency control

View File

@ -6,27 +6,40 @@
IMPORTANT: See <<removal-of-types>>. IMPORTANT: See <<removal-of-types>>.
Adds a JSON document to the specified index and makes Adds a JSON document to the specified data stream or index and makes
it searchable. If the document already exists, it searchable. If the target is an index and the document already exists,
updates the document and increments its version. the request updates the document and increments its version.
NOTE: You cannot send update requests for existing documents to a data stream.
To update a document in a data stream, you must target the backing index
containing the document. See <<update-delete-docs-in-a-data-stream>>.
[[docs-index-api-request]] [[docs-index-api-request]]
==== {api-request-title} ==== {api-request-title}
`PUT /<index>/_doc/<_id>` `PUT /<target>/_doc/<_id>`
`POST /<index>/_doc/` `POST /<target>/_doc/`
`PUT /<index>/_create/<_id>` `PUT /<target>/_create/<_id>`
`POST /<index>/_create/<_id>` `POST /<target>/_create/<_id>`
[[docs-index-api-path-params]] [[docs-index-api-path-params]]
==== {api-path-parms-title} ==== {api-path-parms-title}
`<index>`:: `<target>`::
(Required, string) Name of the target index. By default, the index is created (Required, string) Name of the data stream or index to target.
automatically if it doesn't exist. For more information, see <<index-creation>>. +
If the target doesn't exist and matches the name or wildcard (`*`) pattern of a
<<create-a-data-stream-template,composable template with a `data_stream`
definition>>, this request creates the data stream. See
<<set-up-a-data-stream>>.
+
If the target doesn't exist and doesn't match a data stream template,
this request creates the index.
+
You can check for existing targets using the resolve index API.
`<_id>`:: `<_id>`::
(Optional, string) Unique identifier for the document. Required if you are (Optional, string) Unique identifier for the document. Required if you are
@ -48,6 +61,9 @@ if it does not already exist (_put if absent_). If a document with the specified
`_id` already exists, the indexing operation will fail. Same as using the `_id` already exists, the indexing operation will fail. Same as using the
`<index>/_create` endpoint. Valid values: `index`, `create`. `<index>/_create` endpoint. Valid values: `index`, `create`.
If document id is specified, it defaults to `index`. Otherwise, it defaults to `create`. If document id is specified, it defaults to `index`. Otherwise, it defaults to `create`.
+
NOTE: If the request targets a data stream, an `op_type` of `create` is
required. See <<add-documents-to-a-data-stream>>.
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=pipeline] include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=pipeline]
@ -125,12 +141,19 @@ You can index a new JSON document with the `_doc` or `_create` resource. Using
exist. To update an existing document, you must use the `_doc` resource. exist. To update an existing document, you must use the `_doc` resource.
[[index-creation]] [[index-creation]]
===== Create indices automatically ===== Automatically create data streams and indices
If the specified index does not already exist, by default the index operation If request's target doesn't exist and matches a
automatically creates it and applies any configured <<create-a-data-stream-template,composable template with a `data_stream`
<<indices-templates,index templates>>. If no mapping exists, the index operation definition>>, the index operation automatically creates the data stream. See
creates a dynamic mapping. By default, new fields and objects are <<set-up-a-data-stream>>.
If the target doesn't exist and doesn't match a data stream template,
the operation automatically creates the index and applies any matching
<<indices-templates,index templates>>.
If no mapping exists, the index operation
creates a dynamic mapping. By default, new fields and objects are
automatically added to the mapping if needed. For more information about field automatically added to the mapping if needed. For more information about field
mapping, see <<mapping,mapping>> and the <<indices-put-mapping,put mapping>> API. mapping, see <<mapping,mapping>> and the <<indices-put-mapping,put mapping>> API.
@ -142,6 +165,9 @@ automatic creation of indices that match specified patterns, or set it to
comma-separated list of patterns you want to allow, or prefix each pattern with comma-separated list of patterns you want to allow, or prefix each pattern with
`+` or `-` to indicate whether it should be allowed or blocked. When a list is `+` or `-` to indicate whether it should be allowed or blocked. When a list is
specified, the default behaviour is to disallow. specified, the default behaviour is to disallow.
+
IMPORTANT: The `action.auto_create_index` setting only affects the automatic
creation of indices. It does not affect the creation of data streams.
[source,console] [source,console]
-------------------------------------------------- --------------------------------------------------

View File

@ -452,8 +452,8 @@ end::index-total[]
tag::bulk-index[] tag::bulk-index[]
`_index`:: `_index`::
(Optional, string) (Optional, string)
The name of the target index. Name of the data stream, index, or index alias to perform the action on. This
Required if not specified as a path parameter. parameter is required if a `<target>` is not specified in the request path.
end::bulk-index[] end::bulk-index[]
tag::index-metric[] tag::index-metric[]