Skip to content

Commit 30931cb

Browse files
Add link to _update_by_query API examples (#4705)
* Add link and missing content to update by query * Update specification/_global/update_by_query/UpdateByQueryRequest.ts Co-authored-by: Liam Thompson <[email protected]>
1 parent 644201b commit 30931cb

File tree

2 files changed

+27
-16
lines changed

2 files changed

+27
-16
lines changed

specification/_doc_ids/table.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,7 @@ test-grok-pattern,https://www.elastic.co/docs/api/doc/elasticsearch/operation/op
896896
time-value,https://github.com/elastic/elasticsearch/blob/current/libs/core/src/main/java/org/elasticsearch/core/TimeValue.java,
897897
time-zone-id,https://docs.oracle.com/javase/8/docs/api/java/time/ZoneId.html,
898898
trim-processor,https://www.elastic.co/docs/reference/enrich-processor/trim-processor,
899+
update-by-query,https://www.elastic.co/docs/reference/elasticsearch/rest-apis/update-by-query-api,
899900
update-dfanalytics,https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-update-data-frame-analytics,https://www.elastic.co/guide/en/elasticsearch/reference/8.18/update-dfanalytics.html
900901
update-desired-nodes,https://www.elastic.co/docs/api/doc/elasticsearch/group/endpoint-cluster,https://www.elastic.co/guide/en/elasticsearch/reference/8.18/cluster.html
901902
update-document,https://www.elastic.co/docs/reference/elasticsearch/rest-apis/update-document,https://www.elastic.co/guide/en/elasticsearch/reference/8.18/docs-update.html#update-api-example

specification/_global/update_by_query/UpdateByQueryRequest.ts

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,30 @@ import { Duration } from '@_types/Time'
5959
* Any query or update failures cause the update by query request to fail and the failures are shown in the response.
6060
* Any update requests that completed successfully still stick, they are not rolled back.
6161
*
62+
* **Refreshing shards**
63+
*
64+
* Specifying the `refresh` parameter refreshes all shards once the request completes.
65+
* This is different to the update API's `refresh` parameter, which causes only the shard
66+
* that received the request to be refreshed. Unlike the update API, it does not support
67+
* `wait_for`.
68+
*
69+
* **Running update by query asynchronously**
70+
*
71+
* If the request contains `wait_for_completion=false`, Elasticsearch
72+
* performs some preflight checks, launches the request, and returns a
73+
* [task](https://www.elastic.co/docs/api/doc/elasticsearch/group/endpoint-tasks) you can use to cancel or get the status of the task.
74+
* Elasticsearch creates a record of this task as a document at `.tasks/task/${taskId}`.
75+
*
76+
* **Waiting for active shards**
77+
*
78+
* `wait_for_active_shards` controls how many copies of a shard must be active
79+
* before proceeding with the request. See [`wait_for_active_shards`](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-create#operation-create-wait_for_active_shards)
80+
* for details. `timeout` controls how long each write request waits for unavailable
81+
* shards to become available. Both work exactly the way they work in the
82+
* [Bulk API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-bulk). Update by query uses scrolled searches, so you can also
83+
* specify the `scroll` parameter to control how long it keeps the search context
84+
* alive, for example `?scroll=10m`. The default is 5 minutes.
85+
*
6286
* **Throttling update requests**
6387
*
6488
* 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.
@@ -103,28 +127,14 @@ import { Duration } from '@_types/Time'
103127
* * Update performance scales linearly across available resources with the number of slices.
104128
*
105129
* 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.
130+
* Refer to the linked documentation for examples of how to update documents using the `_update_by_query` API:
122131
* @rest_spec_name update_by_query
123132
* @availability stack since=2.4.0 stability=stable
124133
* @availability serverless stability=stable visibility=public
125134
* @index_privileges read,write
126135
* @doc_tag document
127136
* @doc_id docs-update-by-query
137+
* @ext_doc_id update-by-query
128138
*/
129139
export interface Request extends RequestBase {
130140
urls: [

0 commit comments

Comments
 (0)