Skip to content

Commit e9b6fc8

Browse files
authored
[DOCS] Backport reformat of doc update, delete, and get APIs (#45887)
* [DOCS] Reformat get API. (#45416) * [DOCS] Reformat get API. * [DOCS] Reformat doc delete API reference. (#45422) * [DOCS] Reformat doc delete API reference. * [DOCS] Reformat update API reference. (#45423) * [DOCS] Reformat update API reference. * Fixed bad merge.
1 parent 16bf56f commit e9b6fc8

File tree

5 files changed

+368
-224
lines changed

5 files changed

+368
-224
lines changed

docs/reference/docs/delete.asciidoc

Lines changed: 101 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,35 @@
11
[[docs-delete]]
22
=== Delete API
3+
++++
4+
<titleabbrev>Delete</titleabbrev>
5+
++++
36

4-
The delete API allows to delete a JSON document from a specific
5-
index based on its id. The following example deletes the JSON document
6-
from an index called `twitter` with ID `1`:
7+
Removes a JSON document from the specified index.
78

8-
[source,js]
9-
--------------------------------------------------
10-
DELETE /twitter/_doc/1
11-
--------------------------------------------------
12-
// CONSOLE
13-
// TEST[setup:twitter]
9+
[[docs-delete-api-request]]
10+
==== {api-request-title}
1411

15-
The result of the above delete operation is:
12+
`DELETE /<index>/_doc/<_id>`
1613

17-
[source,js]
18-
--------------------------------------------------
19-
{
20-
"_shards" : {
21-
"total" : 2,
22-
"failed" : 0,
23-
"successful" : 2
24-
},
25-
"_index" : "twitter",
26-
"_type" : "_doc",
27-
"_id" : "1",
28-
"_version" : 2,
29-
"_primary_term": 1,
30-
"_seq_no": 5,
31-
"result": "deleted"
32-
}
33-
--------------------------------------------------
34-
// TESTRESPONSE[s/"successful" : 2/"successful" : 1/]
35-
// TESTRESPONSE[s/"_primary_term" : 1/"_primary_term" : $body._primary_term/]
36-
// TESTRESPONSE[s/"_seq_no" : 5/"_seq_no" : $body._seq_no/]
14+
[[docs-delete-api-desc]]
15+
==== {api-description-title}
16+
17+
You use DELETE to remove a document from an index. You must specify the
18+
index name and document ID.
3719

3820
[float]
3921
[[optimistic-concurrency-control-delete]]
40-
==== Optimistic concurrency control
22+
===== Optimistic concurrency control
4123

4224
Delete operations can be made conditional and only be performed if the last
43-
modification to the document was assigned the sequence number and primary
25+
modification to the document was assigned the sequence number and primary
4426
term specified by the `if_seq_no` and `if_primary_term` parameters. If a
4527
mismatch is detected, the operation will result in a `VersionConflictException`
46-
and a status code of 409. See <<optimistic-concurrency-control>> for more details.
28+
and a status code of 409. See <<optimistic-concurrency-control>> for more details.
4729

4830
[float]
4931
[[delete-versioning]]
50-
==== Versioning
32+
===== Versioning
5133

5234
Each document indexed is versioned. When deleting a document, the `version` can
5335
be specified to make sure the relevant document we are trying to delete is
@@ -60,11 +42,17 @@ determined by the `index.gc_deletes` index setting and defaults to 60 seconds.
6042

6143
[float]
6244
[[delete-routing]]
63-
==== Routing
45+
===== Routing
46+
47+
If routing is used during indexing, the routing value also needs to be
48+
specified to delete a document.
49+
50+
If the `_routing` mapping is set to `required` and no routing value is
51+
specified, the delete API throws a `RoutingMissingException` and rejects
52+
the request.
53+
54+
For example:
6455

65-
When indexing using the ability to control the routing, in order to
66-
delete a document, the routing value should also be provided. For
67-
example:
6856

6957
////
7058
Example to delete with routing
@@ -87,34 +75,29 @@ DELETE /twitter/_doc/1?routing=kimchy
8775
// CONSOLE
8876
// TEST[continued]
8977

90-
The above will delete a tweet with id `1`, but will be routed based on the
91-
user. Note that issuing a delete without the correct routing will cause the
92-
document to not be deleted.
93-
94-
When the `_routing` mapping is set as `required` and no routing value is
95-
specified, the delete API will throw a `RoutingMissingException` and reject
96-
the request.
78+
This request deletes the tweet with id `1`, but it is routed based on the
79+
user. The document is not deleted if the correct routing is not specified.
9780

9881
[float]
9982
[[delete-index-creation]]
100-
==== Automatic index creation
83+
===== Automatic index creation
10184

10285
If an <<docs-index_,external versioning variant>> is used,
103-
the delete operation automatically creates an index if it has not been
104-
created before (check out the <<indices-create-index,create index API>>
105-
for manually creating an index).
86+
the delete operation automatically creates the specified index if it does not
87+
exist. For information about manually creating indices, see
88+
<<indices-create-index,create index API>>.
10689

10790
[float]
10891
[[delete-distributed]]
109-
==== Distributed
92+
===== Distributed
11093

11194
The delete operation gets hashed into a specific shard id. It then gets
11295
redirected into the primary shard within that id group, and replicated
11396
(if needed) to shard replicas within that id group.
11497

11598
[float]
11699
[[delete-wait-for-active-shards]]
117-
==== Wait For Active Shards
100+
===== Wait for active shards
118101

119102
When making delete requests, you can set the `wait_for_active_shards`
120103
parameter to require a minimum number of shard copies to be active
@@ -124,15 +107,14 @@ example.
124107

125108
[float]
126109
[[delete-refresh]]
127-
==== Refresh
110+
===== Refresh
128111

129112
Control when the changes made by this request are visible to search. See
130113
<<docs-refresh>>.
131114

132-
133115
[float]
134116
[[delete-timeout]]
135-
==== Timeout
117+
===== Timeout
136118

137119
The primary shard assigned to perform the delete operation might not be
138120
available when the delete operation is executed. Some reasons for this
@@ -149,3 +131,68 @@ DELETE /twitter/_doc/1?timeout=5m
149131
--------------------------------------------------
150132
// CONSOLE
151133
// TEST[setup:twitter]
134+
135+
[[docs-delete-api-path-params]]
136+
==== {api-path-parms-title}
137+
138+
`<index>`::
139+
(Required, string) Name of the target index.
140+
141+
`<_id>`::
142+
(Required, string) Unique identifier for the document.
143+
144+
[[docs-delete-api-query-params]]
145+
==== {api-query-parms-title}
146+
147+
include::{docdir}/rest-api/common-parms.asciidoc[tag=doc-seq-no]
148+
149+
include::{docdir}/rest-api/common-parms.asciidoc[tag=doc-primary-term]
150+
151+
include::{docdir}/rest-api/common-parms.asciidoc[tag=doc-pipeline]
152+
153+
include::{docdir}/rest-api/common-parms.asciidoc[tag=doc-refresh]
154+
155+
include::{docdir}/rest-api/common-parms.asciidoc[tag=doc-routing]
156+
157+
include::{docdir}/rest-api/common-parms.asciidoc[tag=timeout]
158+
159+
include::{docdir}/rest-api/common-parms.asciidoc[tag=doc-version]
160+
161+
include::{docdir}/rest-api/common-parms.asciidoc[tag=doc-version-type]
162+
163+
include::{docdir}/rest-api/common-parms.asciidoc[tag=doc-wait-for-active-shards]
164+
165+
[[docs-delete-api-example]]
166+
==== {api-examples-title}
167+
168+
Delete the JSON document `1` from the `twitter` index:
169+
170+
[source,js]
171+
--------------------------------------------------
172+
DELETE /twitter/_doc/1
173+
--------------------------------------------------
174+
// CONSOLE
175+
// TEST[setup:twitter]
176+
177+
The API returns the following result:
178+
179+
[source,js]
180+
--------------------------------------------------
181+
{
182+
"_shards" : {
183+
"total" : 2,
184+
"failed" : 0,
185+
"successful" : 2
186+
},
187+
"_index" : "twitter",
188+
"_type" : "_doc",
189+
"_id" : "1",
190+
"_version" : 2,
191+
"_primary_term": 1,
192+
"_seq_no": 5,
193+
"result": "deleted"
194+
}
195+
--------------------------------------------------
196+
// TESTRESPONSE[s/"successful" : 2/"successful" : 1/]
197+
// TESTRESPONSE[s/"_primary_term" : 1/"_primary_term" : $body._primary_term/]
198+
// TESTRESPONSE[s/"_seq_no" : 5/"_seq_no" : $body._seq_no/]

0 commit comments

Comments
 (0)