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
@@ -38,10 +38,93 @@ import { Duration } from '@_types/Time'
38
38
* Update documents.
39
39
* Updates documents that match the specified query.
40
40
* If no query is specified, performs an update on every document in the data stream or index without modifying the source, which is useful for picking up mapping changes.
41
+
*
42
+
* If the Elasticsearch security features are enabled, you must have the following index privileges for the target data stream, index, or alias:
43
+
*
44
+
* * `read`
45
+
* * `index` or `write`
46
+
*
47
+
* You can specify the query criteria in the request URI or the request body using the same syntax as the search API.
48
+
*
49
+
* When you submit an update by query request, Elasticsearch gets a snapshot of the data stream or index when it begins processing the request and updates matching documents using internal versioning.
50
+
* When the versions match, the document is updated and the version number is incremented.
51
+
* If a document changes between the time that the snapshot is taken and the update operation is processed, it results in a version conflict and the operation fails.
52
+
* You can opt to count version conflicts instead of halting and returning by setting `conflicts` to `proceed`.
53
+
* Note that if you opt to count version conflicts, the operation could attempt to update more documents from the source than `max_docs` until it has successfully updated `max_docs` documents or it has gone through every document in the source query.
54
+
*
55
+
* NOTE: Documents with a version equal to 0 cannot be updated using update by query because internal versioning does not support 0 as a valid version number.
56
+
*
57
+
* While processing an update by query request, Elasticsearch performs multiple search requests sequentially to find all of the matching documents.
58
+
* A bulk update request is performed for each batch of matching documents.
59
+
* Any query or update failures cause the update by query request to fail and the failures are shown in the response.
60
+
* Any update requests that completed successfully still stick, they are not rolled back.
61
+
*
62
+
* **Throttling update requests**
63
+
*
64
+
* To control the rate at which update by query issues batches of update operations, you can set `requests_per_second` to any positive decimal number.
65
+
* This pads each batch with a wait time to throttle the rate.
66
+
* Set `requests_per_second` to `-1` to turn off throttling.
67
+
*
68
+
* 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.
69
+
* The padding time is the difference between the batch size divided by the `requests_per_second` and the time spent writing.
70
+
* 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.
78
+
* This is "bursty" instead of "smooth".
79
+
*
80
+
* **Slicing**
81
+
*
82
+
* Update by query supports sliced scroll to parallelize the update process.
83
+
* This can improve efficiency and provide a convenient way to break the request down into smaller parts.
84
+
*
85
+
* Setting `slices` to `auto` chooses a reasonable number for most data streams and indices.
86
+
* This setting will use one slice per shard, up to a certain limit.
87
+
* 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.
88
+
*
89
+
* Adding `slices` to `_update_by_query` just automates the manual process of creating sub-requests, which means it has some quirks:
90
+
*
91
+
* * You can see these requests in the tasks APIs. These sub-requests are "child" tasks of the task for the request with slices.
92
+
* * Fetching the status of the task for the request with `slices` only contains the status of completed slices.
93
+
* * These sub-requests are individually addressable for things like cancellation and rethrottling.
94
+
* * Rethrottling the request with `slices` will rethrottle the unfinished sub-request proportionally.
95
+
* * Canceling the request with slices will cancel each sub-request.
96
+
* * 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.
97
+
* * Parameters like `requests_per_second` and `max_docs` on a request with slices are distributed proportionally to each sub-request. Combine that with the point above about distribution being uneven and you should conclude that using `max_docs` with `slices` might not result in exactly `max_docs` documents being updated.
98
+
* * 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.
99
+
*
100
+
* If you're slicing manually or otherwise tuning automatic slicing, keep in mind that:
101
+
*
102
+
* * 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.
103
+
* * Update performance scales linearly across available resources with the number of slices.
104
+
*
105
+
* Whether query or update performance dominates the runtime depends on the documents being reindexed and cluster resources.
106
+
*
107
+
* **Update the document source**
108
+
*
109
+
* Update by query supports scripts to update the document source.
110
+
* As with the update API, you can set `ctx.op` to change the operation that is performed.
111
+
*
112
+
* Set `ctx.op = "noop"` if your script decides that it doesn't have to make any changes.
113
+
* The update by query operation skips updating the document and increments the `noop` counter.
114
+
*
115
+
* Set `ctx.op = "delete"` if your script decides that the document should be deleted.
116
+
* The update by query operation deletes the document and increments the `deleted` counter.
117
+
*
118
+
* Update by query supports only `index`, `noop`, and `delete`.
119
+
* Setting `ctx.op` to anything else is an error.
120
+
* Setting any other field in `ctx` is an error.
121
+
* This API enables you to only modify the source of matching documents; you cannot move them.
* The number of shard copies that must be active before proceeding with the operation.
200
298
* Set to `all` or any positive integer up to the total number of shards in the index (`number_of_replicas+1`).
299
+
* The `timeout` parameter controls how long each write request waits for unavailable shards to become available.
300
+
* Both work exactly the way they work in the bulk API.
201
301
* @server_default 1
202
302
*/
203
303
wait_for_active_shards?: WaitForActiveShards
204
304
/**
205
305
* If `true`, the request blocks until the operation is complete.
306
+
* If `false`, Elasticsearch performs some preflight checks, launches the request, and returns a task ID that you can use to cancel or get the status of the task.
307
+
* Elasticsearch creates a record of this task as a document at `.tasks/task/${taskId}`.
/** The number of scroll responses pulled back by the update by query. */
28
29
batches?: long
30
+
/**
31
+
* Array of failures if there were any unrecoverable errors during the process.
32
+
* If this is non-empty then the request ended because of those failures.
33
+
* Update by query is implemented using batches.
34
+
* Any failure causes the entire process to end, but all failures in the current batch are collected into the array.
35
+
* You can use the `conflicts` option to prevent reindex from ending when version conflicts occur. */
29
36
failures?: BulkIndexByScrollFailure[]
37
+
/** The number of documents that were ignored because the script used for the update by query returned a noop value for `ctx.op`. */
30
38
noops?: long
39
+
/** The number of documents that were successfully deleted. */
31
40
deleted?: long
41
+
/** The number of requests per second effectively run during the update by query. */
32
42
requests_per_second?: float
43
+
/**
44
+
* The number of retries attempted by update by query.
45
+
* `bulk` is the number of bulk actions retried.
46
+
* `search` is the number of search actions retried. */
33
47
retries?: Retries
34
48
task?: TaskId
49
+
/** If true, some requests timed out during the update by query. */
35
50
timed_out?: boolean
51
+
/** The number of milliseconds from start to end of the whole operation. */
36
52
took?: DurationValue<UnitMillis>
53
+
/** The number of documents that were successfully processed. */
37
54
total?: long
55
+
/** The number of documents that were successfully updated. */
38
56
updated?: long
57
+
/** The number of version conflicts that the update by query hit. */
39
58
version_conflicts?: long
40
59
throttled?: Duration
60
+
/** The number of milliseconds the request slept to conform to `requests_per_second`. */
41
61
throttled_millis?: DurationValue<UnitMillis>
42
62
throttled_until?: Duration
63
+
/** This field should always be equal to zero in an _update_by_query response.
64
+
* It only has meaning 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