6
6
7
7
IMPORTANT: See <<removal-of-types>>.
8
8
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>>.
12
16
13
17
[[docs-index-api-request]]
14
18
==== {api-request-title}
15
19
16
- `PUT /<index >/_doc/<_id>`
20
+ `PUT /<target >/_doc/<_id>`
17
21
18
- `POST /<index >/_doc/`
22
+ `POST /<target >/_doc/`
19
23
20
- `PUT /<index >/_create/<_id>`
24
+ `PUT /<target >/_create/<_id>`
21
25
22
- `POST /<index >/_create/<_id>`
26
+ `POST /<target >/_create/<_id>`
23
27
24
28
[[docs-index-api-path-params]]
25
29
==== {api-path-parms-title}
26
30
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.
30
43
31
44
`<_id>`::
32
45
(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
48
61
`_id` already exists, the indexing operation will fail. Same as using the
49
62
`<index>/_create` endpoint. Valid values: `index`, `create`.
50
63
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>>.
51
67
52
68
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=pipeline]
53
69
@@ -125,12 +141,19 @@ You can index a new JSON document with the `_doc` or `_create` resource. Using
125
141
exist. To update an existing document, you must use the `_doc` resource.
126
142
127
143
[[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>>.
129
150
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
134
157
automatically added to the mapping if needed. For more information about field
135
158
mapping, see <<mapping,mapping>> and the <<indices-put-mapping,put mapping>> API.
136
159
@@ -142,6 +165,9 @@ automatic creation of indices that match specified patterns, or set it to
142
165
comma-separated list of patterns you want to allow, or prefix each pattern with
143
166
`+` or `-` to indicate whether it should be allowed or blocked. When a list is
144
167
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.
145
171
146
172
[source,console]
147
173
--------------------------------------------------
0 commit comments