Skip to content

Commit 48f4a8d

Browse files
authored
[DOCS] Add data streams to bulk, delete, and index API docs (#58340)
Updates existing docs for the bulk, delete and index APIs to make them aware of data streams.
1 parent 433ab42 commit 48f4a8d

File tree

4 files changed

+65
-26
lines changed

4 files changed

+65
-26
lines changed

docs/reference/docs/bulk.asciidoc

+18-9
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ POST _bulk
2424

2525
`POST /_bulk`
2626

27-
`POST /<index>/_bulk`
27+
`POST /<target>/_bulk`
2828

2929
[[docs-bulk-api-desc]]
3030
==== {api-description-title}
@@ -47,8 +47,12 @@ optional_source\n
4747

4848
The `index` and `create` actions expect a source on the next line,
4949
and have the same semantics as the `op_type` parameter in the standard index API:
50-
create fails if a document with the same name already exists in the index,
51-
index adds or replaces a document as necessary.
50+
`create` fails if a document with the same ID already exists in the target,
51+
`index` adds or replaces a document as necessary.
52+
53+
NOTE: <<data-streams,Data streams>> support only the `create` action. To update
54+
or delete a document in a data stream, you must target the backing index
55+
containing the document. See <<update-delete-docs-in-a-data-stream>>.
5256

5357
`update` expects that the partial doc, upsert,
5458
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`.
6771
Because this format uses literal `\n`'s as delimiters,
6872
make sure that the JSON actions and sources are not pretty printed.
6973

70-
If you specify an index in the request URI,
71-
it is used for any actions that don't explicitly specify an index.
74+
If you provide a `<target>` in the request path,
75+
it is used for any actions that don't explicitly specify an `_index` argument.
7276

7377
A note on the format: The idea here is to make processing of this as
7478
fast as possible. As some of the actions are redirected to other
@@ -192,8 +196,10 @@ See <<url-access-control>>.
192196
[[docs-bulk-api-path-params]]
193197
==== {api-path-parms-title}
194198

195-
`<index>`::
196-
(Optional, string) Name of the index to perform the bulk actions against.
199+
`<target>`::
200+
(Optional, string)
201+
Name of the data stream, index, or index alias to perform bulk actions
202+
on.
197203

198204
[[docs-bulk-api-query-params]]
199205
==== {api-query-parms-title}
@@ -321,7 +327,8 @@ operation.
321327
=====
322328
`_index`::
323329
(string)
324-
The index name or alias associated with the operation.
330+
Name of the index associated with the operation. If the operation targeted a
331+
data stream, this is the backing index into which the document was written.
325332

326333
`_id`::
327334
(integer)
@@ -410,7 +417,9 @@ ID of the shard associated with the failed operation.
410417
411418
`index`::
412419
(string)
413-
The index name or alias associated with the failed operation.
420+
Name of the index associated with the failed operation. If the operation
421+
targeted a data stream, this is the backing index into which the document was
422+
attempted to be written.
414423
======
415424
=====
416425
====

docs/reference/docs/delete.asciidoc

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ Removes a JSON document from the specified index.
1717
You use DELETE to remove a document from an index. You must specify the
1818
index name and document ID.
1919

20+
NOTE: You cannot send deletion requests directly to a data stream. To delete a
21+
document in a data stream, you must target the backing index containing the
22+
document. See <<update-delete-docs-in-a-data-stream>>.
23+
2024
[float]
2125
[[optimistic-concurrency-control-delete]]
2226
===== Optimistic concurrency control

docs/reference/docs/index_.asciidoc

+41-15
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,40 @@
66

77
IMPORTANT: See <<removal-of-types>>.
88

9-
Adds a JSON document to the specified index and makes
10-
it searchable. If the document already exists,
11-
updates the document and increments its version.
9+
Adds a JSON document to the specified data stream or index and makes
10+
it searchable. If the target is an index and the document already exists,
11+
the request updates the document and increments its version.
12+
13+
NOTE: You cannot send update requests for existing documents to a data stream.
14+
To update a document in a data stream, you must target the backing index
15+
containing the document. See <<update-delete-docs-in-a-data-stream>>.
1216

1317
[[docs-index-api-request]]
1418
==== {api-request-title}
1519

16-
`PUT /<index>/_doc/<_id>`
20+
`PUT /<target>/_doc/<_id>`
1721

18-
`POST /<index>/_doc/`
22+
`POST /<target>/_doc/`
1923

20-
`PUT /<index>/_create/<_id>`
24+
`PUT /<target>/_create/<_id>`
2125

22-
`POST /<index>/_create/<_id>`
26+
`POST /<target>/_create/<_id>`
2327

2428
[[docs-index-api-path-params]]
2529
==== {api-path-parms-title}
2630

27-
`<index>`::
28-
(Required, string) Name of the target index. By default, the index is created
29-
automatically if it doesn't exist. For more information, see <<index-creation>>.
31+
`<target>`::
32+
(Required, string) Name of the data stream or index to target.
33+
+
34+
If the target doesn't exist and matches the name or wildcard (`*`) pattern of a
35+
<<create-a-data-stream-template,composable template with a `data_stream`
36+
definition>>, this request creates the data stream. See
37+
<<set-up-a-data-stream>>.
38+
+
39+
If the target doesn't exist and doesn't match a data stream template,
40+
this request creates the index.
41+
+
42+
You can check for existing targets using the resolve index API.
3043

3144
`<_id>`::
3245
(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
4861
`_id` already exists, the indexing operation will fail. Same as using the
4962
`<index>/_create` endpoint. Valid values: `index`, `create`.
5063
If document id is specified, it defaults to `index`. Otherwise, it defaults to `create`.
64+
+
65+
NOTE: If the request targets a data stream, an `op_type` of `create` is
66+
required. See <<add-documents-to-a-data-stream>>.
5167

5268
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=pipeline]
5369

@@ -125,12 +141,19 @@ You can index a new JSON document with the `_doc` or `_create` resource. Using
125141
exist. To update an existing document, you must use the `_doc` resource.
126142

127143
[[index-creation]]
128-
===== Create indices automatically
144+
===== Automatically create data streams and indices
145+
146+
If request's target doesn't exist and matches a
147+
<<create-a-data-stream-template,composable template with a `data_stream`
148+
definition>>, the index operation automatically creates the data stream. See
149+
<<set-up-a-data-stream>>.
129150

130-
If the specified index does not already exist, by default the index operation
131-
automatically creates it and applies any configured
132-
<<indices-templates,index templates>>. If no mapping exists, the index operation
133-
creates a dynamic mapping. By default, new fields and objects are
151+
If the target doesn't exist and doesn't match a data stream template,
152+
the operation automatically creates the index and applies any matching
153+
<<indices-templates,index templates>>.
154+
155+
If no mapping exists, the index operation
156+
creates a dynamic mapping. By default, new fields and objects are
134157
automatically added to the mapping if needed. For more information about field
135158
mapping, see <<mapping,mapping>> and the <<indices-put-mapping,put mapping>> API.
136159

@@ -142,6 +165,9 @@ automatic creation of indices that match specified patterns, or set it to
142165
comma-separated list of patterns you want to allow, or prefix each pattern with
143166
`+` or `-` to indicate whether it should be allowed or blocked. When a list is
144167
specified, the default behaviour is to disallow.
168+
+
169+
IMPORTANT: The `action.auto_create_index` setting only affects the automatic
170+
creation of indices. It does not affect the creation of data streams.
145171

146172
[source,console]
147173
--------------------------------------------------

docs/reference/rest-api/common-parms.asciidoc

+2-2
Original file line numberDiff line numberDiff line change
@@ -430,8 +430,8 @@ end::index-total[]
430430
tag::bulk-index[]
431431
`_index`::
432432
(Optional, string)
433-
The name of the target index.
434-
Required if not specified as a path parameter.
433+
Name of the data stream, index, or index alias to perform the action on. This
434+
parameter is required if a `<target>` is not specified in the request path.
435435
end::bulk-index[]
436436

437437
tag::index-metric[]

0 commit comments

Comments
 (0)