You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -35,11 +35,91 @@ import { Duration } from '@_types/Time'
35
35
36
36
/**
37
37
* Delete documents.
38
+
*
38
39
* Deletes documents that match the specified query.
40
+
*
41
+
* If the Elasticsearch security features are enabled, you must have the following index privileges for the target data stream, index, or alias:
42
+
*
43
+
* * `read`
44
+
* * `delete` or `write`
45
+
*
46
+
* You can specify the query criteria in the request URI or the request body using the same syntax as the search API.
47
+
* When you submit a delete by query request, Elasticsearch gets a snapshot of the data stream or index when it begins processing the request and deletes matching documents using internal versioning.
48
+
* If a document changes between the time that the snapshot is taken and the delete operation is processed, it results in a version conflict and the delete operation fails.
49
+
*
50
+
* NOTE: Documents with a version equal to 0 cannot be deleted using delete by query because internal versioning does not support 0 as a valid version number.
51
+
*
52
+
* While processing a delete by query request, Elasticsearch performs multiple search requests sequentially to find all of the matching documents to delete.
53
+
* A bulk delete request is performed for each batch of matching documents.
54
+
* If a search or bulk request is rejected, the requests are retried up to 10 times, with exponential back off.
55
+
* If the maximum retry limit is reached, processing halts and all failed requests are returned in the response.
56
+
* Any delete requests that completed successfully still stick, they are not rolled back.
57
+
*
58
+
* You can opt to count version conflicts instead of halting and returning by setting `conflicts` to `proceed`.
59
+
* Note that if you opt to count version conflicts the operation could attempt to delete more documents from the source than `max_docs` until it has successfully deleted `max_docs documents`, or it has gone through every document in the source query.
60
+
*
61
+
* **Throttling delete requests**
62
+
*
63
+
* To control the rate at which delete by query issues batches of delete operations, you can set `requests_per_second` to any positive decimal number.
64
+
* This pads each batch with a wait time to throttle the rate.
65
+
* Set `requests_per_second` to `-1` to disable throttling.
66
+
*
67
+
* Throttling uses a wait time between batches so that the internal scroll requests can be given a timeout that takes the request padding into account.
68
+
* The padding time is the difference between the batch size divided by the `requests_per_second` and the time spent writing.
69
+
* By default the batch size is `1000`, so if `requests_per_second` is set to `500`:
* Since the batch is issued as a single `_bulk` request, large batch sizes cause Elasticsearch to create many requests and wait before starting the next set.
77
+
* This is "bursty" instead of "smooth".
78
+
*
79
+
* **Slicing**
80
+
*
81
+
* Delete by query supports sliced scroll to parallelize the delete process.
82
+
* This can improve efficiency and provide a convenient way to break the request down into smaller parts.
83
+
*
84
+
* Setting `slices` to `auto` lets Elasticsearch choose the number of slices to use.
85
+
* This setting will use one slice per shard, up to a certain limit.
86
+
* If there are multiple source data streams or indices, it will choose the number of slices based on the index or backing index with the smallest number of shards.
87
+
* Adding slices to the delete by query operation creates sub-requests which means it has some quirks:
88
+
*
89
+
* * You can see these requests in the tasks APIs. These sub-requests are "child" tasks of the task for the request with slices.
90
+
* * Fetching the status of the task for the request with slices only contains the status of completed slices.
91
+
* * These sub-requests are individually addressable for things like cancellation and rethrottling.
92
+
* * Rethrottling the request with `slices` will rethrottle the unfinished sub-request proportionally.
93
+
* * Canceling the request with `slices` will cancel each sub-request.
94
+
* * Due to the nature of `slices` each sub-request won't get a perfectly even portion of the documents. All documents will be addressed, but some slices may be larger than others. Expect larger slices to have a more even distribution.
95
+
* * Parameters like `requests_per_second` and `max_docs` on a request with `slices` are distributed proportionally to each sub-request. Combine that with the earlier point about distribution being uneven and you should conclude that using `max_docs` with `slices` might not result in exactly `max_docs` documents being deleted.
96
+
* * Each sub-request gets a slightly different snapshot of the source data stream or index though these are all taken at approximately the same time.
97
+
*
98
+
* If you're slicing manually or otherwise tuning automatic slicing, keep in mind that:
99
+
*
100
+
* * Query performance is most efficient when the number of slices is equal to the number of shards in the index or backing index. If that number is large (for example, 500), choose a lower number as too many `slices` hurts performance. Setting `slices` higher than the number of shards generally does not improve efficiency and adds overhead.
101
+
* * Delete performance scales linearly across available resources with the number of slices.
102
+
*
103
+
* Whether query or delete performance dominates the runtime depends on the documents being reindexed and cluster resources.
104
+
*
105
+
* **Cancel a delete by query operation**
106
+
*
107
+
* Any delete by query can be canceled using the task cancel API. For example:
108
+
*
109
+
* ```
110
+
* POST _tasks/r1A2WoRbTwKZ516z6NEs5A:36619/_cancel
111
+
* ```
112
+
*
113
+
* The task ID can be found by using the get tasks API.
114
+
*
115
+
* Cancellation should happen quickly but might take a few seconds.
116
+
* The get task status API will continue to list the delete by query task until this task checks that it has been cancelled and terminates itself.
* The number of shard copies that must be active before proceeding with the operation.
193
-
* Set to all or any positive integer up to the total number of shards in the index (`number_of_replicas+1`).
284
+
* Set to `all` or any positive integer up to the total number of shards in the index (`number_of_replicas+1`).
285
+
* The `timeout` value controls how long each write request waits for unavailable shards to become available.
194
286
* @server_default 1
195
287
*/
196
288
wait_for_active_shards?: WaitForActiveShards
197
289
/**
198
290
* If `true`, the request blocks until the operation is complete.
291
+
* If `false`, Elasticsearch performs some preflight checks, launches the request, and returns a task you can use to cancel or get the status of the task. Elasticsearch creates a record of this task as a document at `.tasks/task/${taskId}`. When you are done with a task, you should delete the task document so Elasticsearch can reclaim the space.
* The number of scroll responses pulled back by the delete by query.
30
+
*/
28
31
batches?: long
32
+
/**
33
+
* The number of documents that were successfully deleted.
34
+
*/
29
35
deleted?: long
36
+
/**
37
+
* An array of failures if there were any unrecoverable errors during the process.
38
+
* If this array is not empty, the request ended abnormally because of those failures.
39
+
* Delete by query is implemented using batches and any failures cause the entire process to end but all failures in the current batch are collected into the array.
40
+
* You can use the `conflicts` option to prevent reindex from ending on version conflicts.
41
+
*/
30
42
failures?: BulkIndexByScrollFailure[]
43
+
/**
44
+
* This field is always equal to zero for delete by query.
45
+
* It exists only so that delete by query, update by query, and reindex APIs return responses with the same structure.
46
+
*/
31
47
noops?: long
48
+
/**
49
+
* The number of requests per second effectively run during the delete by query.
50
+
*/
32
51
requests_per_second?: float
52
+
/**
53
+
* The number of retries attempted by delete by query.
54
+
* `bulk` is the number of bulk actions retried.
55
+
* `search` is the number of search actions retried.
56
+
*/
33
57
retries?: Retries
34
58
slice_id?: integer
35
59
task?: TaskId
36
60
throttled?: Duration
61
+
/**
62
+
* The number of milliseconds the request slept to conform to `requests_per_second`.
63
+
*/
37
64
throttled_millis?: DurationValue<UnitMillis>
38
65
throttled_until?: Duration
66
+
/**
67
+
* This field should always be equal to zero in a `_delete_by_query` response.
68
+
* It has meaning only when using the task API, where it indicates the next time (in milliseconds since epoch) a throttled request will be run again in order to conform to `requests_per_second`.
0 commit comments