@@ -17,10 +17,6 @@ Removes a JSON document from the specified index.
17
17
`<index>`::
18
18
(Required, string) Name of the target index.
19
19
20
- `_doc`::
21
- (Required, string) Document type. {es} indices now support a
22
- single document type, `_doc`.
23
-
24
20
`<_id>`::
25
21
(Required, string) Unique identifier for the document.
26
22
@@ -45,44 +41,15 @@ include::{docdir}/rest-api/common-parms.asciidoc[tag-doc-version-type]
45
41
46
42
include::{docdir}/rest-api/common-parms.asciidoc[tag-doc-wait-for-active-shards]
47
43
48
- [[docs-delete-api-example ]]
49
- ==== {api-examples -title}
44
+ [[docs-delete-api-desc ]]
45
+ ==== {api-description -title}
50
46
51
- Delete the JSON document `1` from the `twitter` index:
52
-
53
- [source,js]
54
- --------------------------------------------------
55
- DELETE /twitter/_doc/1
56
- --------------------------------------------------
57
- // CONSOLE
58
- // TEST[setup:twitter]
59
-
60
- The result of the above delete operation is:
61
-
62
- [source,js]
63
- --------------------------------------------------
64
- {
65
- "_shards" : {
66
- "total" : 2,
67
- "failed" : 0,
68
- "successful" : 2
69
- },
70
- "_index" : "twitter",
71
- "_type" : "_doc",
72
- "_id" : "1",
73
- "_version" : 2,
74
- "_primary_term": 1,
75
- "_seq_no": 5,
76
- "result": "deleted"
77
- }
78
- --------------------------------------------------
79
- // TESTRESPONSE[s/"successful" : 2/"successful" : 1/]
80
- // TESTRESPONSE[s/"_primary_term" : 1/"_primary_term" : $body._primary_term/]
81
- // TESTRESPONSE[s/"_seq_no" : 5/"_seq_no" : $body._seq_no/]
47
+ You use DELETE to remove a document from an index. You must specify the
48
+ index name and document ID.
82
49
83
50
[float]
84
51
[[optimistic-concurrency-control-delete]]
85
- ==== Optimistic concurrency control
52
+ ===== Optimistic concurrency control
86
53
87
54
Delete operations can be made conditional and only be performed if the last
88
55
modification to the document was assigned the sequence number and primary
@@ -92,7 +59,7 @@ and a status code of 409. See <<optimistic-concurrency-control>> for more detail
92
59
93
60
[float]
94
61
[[delete-versioning]]
95
- ==== Versioning
62
+ ===== Versioning
96
63
97
64
Each document indexed is versioned. When deleting a document, the `version` can
98
65
be specified to make sure the relevant document we are trying to delete is
@@ -105,11 +72,17 @@ determined by the `index.gc_deletes` index setting and defaults to 60 seconds.
105
72
106
73
[float]
107
74
[[delete-routing]]
108
- ==== Routing
75
+ ===== Routing
76
+
77
+ If routing is used during indexing, the routing value also needs to be
78
+ specified to delete a document.
79
+
80
+ If the `_routing` mapping is set to `required` and no routing value is
81
+ specified, the delete API throws a `RoutingMissingException` and rejects
82
+ the request.
83
+
84
+ For example:
109
85
110
- When indexing using the ability to control the routing, in order to
111
- delete a document, the routing value should also be provided. For
112
- example:
113
86
114
87
////
115
88
Example to delete with routing
@@ -132,34 +105,29 @@ DELETE /twitter/_doc/1?routing=kimchy
132
105
// CONSOLE
133
106
// TEST[continued]
134
107
135
- The above will delete a tweet with id `1`, but will be routed based on the
136
- user. Note that issuing a delete without the correct routing will cause the
137
- document to not be deleted.
138
-
139
- When the `_routing` mapping is set as `required` and no routing value is
140
- specified, the delete API will throw a `RoutingMissingException` and reject
141
- the request.
108
+ This request deletes the tweet with id `1, but it is routed based on the
109
+ user. The document is not deleted if the correct routing is not specified.
142
110
143
111
[float]
144
112
[[delete-index-creation]]
145
- ==== Automatic index creation
113
+ ===== Automatic index creation
146
114
147
115
If an <<docs-index_,external versioning variant>> is used,
148
- the delete operation automatically creates an index if it has not been
149
- created before (check out the << indices-create-index,create index API>>
150
- for manually creating an index).
116
+ the delete operation automatically creates the specified index if it does not
117
+ exist. (For information about manually creating indices, see
118
+ <<indices-create-index,create index API>>.)
151
119
152
120
[float]
153
121
[[delete-distributed]]
154
- ==== Distributed
122
+ ===== Distributed
155
123
156
124
The delete operation gets hashed into a specific shard id. It then gets
157
125
redirected into the primary shard within that id group, and replicated
158
126
(if needed) to shard replicas within that id group.
159
127
160
128
[float]
161
129
[[delete-wait-for-active-shards]]
162
- ==== Wait For Active Shards
130
+ ===== Wait for active shards
163
131
164
132
When making delete requests, you can set the `wait_for_active_shards`
165
133
parameter to require a minimum number of shard copies to be active
@@ -169,15 +137,15 @@ example.
169
137
170
138
[float]
171
139
[[delete-refresh]]
172
- ==== Refresh
140
+ ===== Refresh
173
141
174
142
Control when the changes made by this request are visible to search. See
175
143
<<docs-refresh>>.
176
144
177
145
178
146
[float]
179
147
[[delete-timeout]]
180
- ==== Timeout
148
+ ===== Timeout
181
149
182
150
The primary shard assigned to perform the delete operation might not be
183
151
available when the delete operation is executed. Some reasons for this
@@ -194,3 +162,38 @@ DELETE /twitter/_doc/1?timeout=5m
194
162
--------------------------------------------------
195
163
// CONSOLE
196
164
// TEST[setup:twitter]
165
+
166
+ [[docs-delete-api-example]]
167
+ ==== {api-examples-title}
168
+
169
+ Delete the JSON document `1` from the `twitter` index:
170
+
171
+ [source,js]
172
+ --------------------------------------------------
173
+ DELETE /twitter/_doc/1
174
+ --------------------------------------------------
175
+ // CONSOLE
176
+ // TEST[setup:twitter]
177
+
178
+ The API returns the following result:
179
+
180
+ [source,js]
181
+ --------------------------------------------------
182
+ {
183
+ "_shards" : {
184
+ "total" : 2,
185
+ "failed" : 0,
186
+ "successful" : 2
187
+ },
188
+ "_index" : "twitter",
189
+ "_type" : "_doc",
190
+ "_id" : "1",
191
+ "_version" : 2,
192
+ "_primary_term": 1,
193
+ "_seq_no": 5,
194
+ "result": "deleted"
195
+ }
196
+ --------------------------------------------------
197
+ // TESTRESPONSE[s/"successful" : 2/"successful" : 1/]
198
+ // TESTRESPONSE[s/"_primary_term" : 1/"_primary_term" : $body._primary_term/]
199
+ // TESTRESPONSE[s/"_seq_no" : 5/"_seq_no" : $body._seq_no/]
0 commit comments