Skip to content

Commit 8873f5e

Browse files
committed
Edits to sync with index API.
1 parent d48850a commit 8873f5e

File tree

1 file changed

+61
-58
lines changed

1 file changed

+61
-58
lines changed

docs/reference/docs/delete.asciidoc

Lines changed: 61 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ Removes a JSON document from the specified index.
1717
`<index>`::
1818
(Required, string) Name of the target index.
1919

20-
`_doc`::
21-
(Required, string) Document type. {es} indices now support a
22-
single document type, `_doc`.
23-
2420
`<_id>`::
2521
(Required, string) Unique identifier for the document.
2622

@@ -45,44 +41,15 @@ include::{docdir}/rest-api/common-parms.asciidoc[tag-doc-version-type]
4541

4642
include::{docdir}/rest-api/common-parms.asciidoc[tag-doc-wait-for-active-shards]
4743

48-
[[docs-delete-api-example]]
49-
==== {api-examples-title}
44+
[[docs-delete-api-desc]]
45+
==== {api-description-title}
5046

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.
8249

8350
[float]
8451
[[optimistic-concurrency-control-delete]]
85-
==== Optimistic concurrency control
52+
===== Optimistic concurrency control
8653

8754
Delete operations can be made conditional and only be performed if the last
8855
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
9259

9360
[float]
9461
[[delete-versioning]]
95-
==== Versioning
62+
===== Versioning
9663

9764
Each document indexed is versioned. When deleting a document, the `version` can
9865
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.
10572

10673
[float]
10774
[[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:
10985

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:
11386

11487
////
11588
Example to delete with routing
@@ -132,34 +105,29 @@ DELETE /twitter/_doc/1?routing=kimchy
132105
// CONSOLE
133106
// TEST[continued]
134107

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.
142110

143111
[float]
144112
[[delete-index-creation]]
145-
==== Automatic index creation
113+
===== Automatic index creation
146114

147115
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>>.)
151119

152120
[float]
153121
[[delete-distributed]]
154-
==== Distributed
122+
===== Distributed
155123

156124
The delete operation gets hashed into a specific shard id. It then gets
157125
redirected into the primary shard within that id group, and replicated
158126
(if needed) to shard replicas within that id group.
159127

160128
[float]
161129
[[delete-wait-for-active-shards]]
162-
==== Wait For Active Shards
130+
===== Wait for active shards
163131

164132
When making delete requests, you can set the `wait_for_active_shards`
165133
parameter to require a minimum number of shard copies to be active
@@ -169,15 +137,15 @@ example.
169137

170138
[float]
171139
[[delete-refresh]]
172-
==== Refresh
140+
===== Refresh
173141

174142
Control when the changes made by this request are visible to search. See
175143
<<docs-refresh>>.
176144

177145

178146
[float]
179147
[[delete-timeout]]
180-
==== Timeout
148+
===== Timeout
181149

182150
The primary shard assigned to perform the delete operation might not be
183151
available when the delete operation is executed. Some reasons for this
@@ -194,3 +162,38 @@ DELETE /twitter/_doc/1?timeout=5m
194162
--------------------------------------------------
195163
// CONSOLE
196164
// 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

Comments
 (0)