쿼리로 문서 업데이트 API (Update By Query API)
Update by Query API는 지정한 쿼리와 일치하는 인덱스의 모든 문서를 업데이트해요. 문서의 소스를 바꾸지 않으면서 매핑 변경 사항을 반영하도록 업데이트할 수도 있고, 스크립트를 사용해 커스텀 로직에 따라 필드 값을 수정할 수도 있습니다.
이 API를 다음 시나리오에서 사용해요.
- 새 필드를 추가하거나 필드 타입을 바꾼 뒤 기존 문서에 매핑 변경 사항을 적용할 때.
- 계산된 로직이나 조건에 따라 여러 문서의 필드 값을 업데이트할 때.
- 특정 기준에 맞는 문서의 카운터를 증가시키거나 대량 계산을 수행할 때.
- 스크립트에서 ctx.op = "delete"를 설정해 조건부로 문서를 삭제할 때.
- 조건이 충족되지 않을 때 ctx.op = "noop"를 설정해 무연산(no-op) 업데이트를 수행할 때. update by query 요청을 제출하면 OpenSearch는 연산 시작 시점에 인덱스의 스냅샷을 찍고 내부 버전 관리를 사용해 일치하는 문서를 업데이트합니다. 스냅샷이 찍힌 시점과 업데이트 연산이 문서를 처리하는 시점 사이에 문서가 변경되면 버전 충돌이 발생하고, conflicts 파라미터를 proceed로 설정하지 않는 한 해당 문서의 업데이트는 실패해요. 버전 충돌이 중단을 일으키지 않으면 문서는 업데이트되고 버전 번호가 증가합니다. 성공적으로 업데이트된 문서는 이후 배치의 연산이 실패하더라도 롤백되지 않아요.
모든 업데이트 및 쿼리 실패는 연산을 중단시키고 응답의 failures 배열에 반환됩니다. 성공적인 업데이트는 중단 이후에도 유지됩니다. 첫 번째 실패가 중단을 유발하지만, 거부된 bulk 요청의 모든 실패가 failures 요소에 나타나므로 여러 실패 엔티티가 보고될 수 있어요.
OpenSearch는 거부된 검색 또는 bulk 요청을 지수 백오프로 최대 10번 재시도합니다. 최대 재시도 한도에 도달하면 연산이 중단되고 모든 실패 요청을 응답에 반환해요.
Note: OpenSearch는 버전 0인 문서는 이 API로 업데이트할 수 없어요. 내부 버전 관리 시스템은 업데이트 연산을 올바르게 추적하고 처리하려면 버전 번호가 0보다 커야 합니다.
출처: OpenSearch 문서
본문
Endpoints
POST /{index}/_update_by_query
Path parameters
다음 표는 사용 가능한 경로 파라미터를 보여줘요.
| Parameter | Required | Data type | Description | | index | Required | List or String | A comma-separated list of data streams, indexes, and aliases to search. Supports wildcards (*). To search all data streams or indexes, omit this parameter or use * or _all. |
Query parameters
다음 표는 사용 가능한 쿼리 파라미터를 보여줘요. 모든 쿼리 파라미터는 선택사항이에요.
| Parameter | Data type | Description | Default | | _source | Boolean or List or String | Set to true or false to return the _source field or not, or a list of fields to return. | N/A | | _source_excludes | List | List of fields to exclude from the returned _source field. | N/A | | _source_includes | List | List of fields to extract and return from the _source field. | N/A | | allow_no_indices | Boolean | If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes. For example, a request targeting foo*,bar* returns an error if an index starts with foo but no index starts with bar. | N/A | | analyze_wildcard | Boolean | If true, wildcard and prefix queries are analyzed. | false | | analyzer | String | Analyzer to use for the query string. | N/A | | conflicts | String | What to do if update by query hits version conflicts: abort or proceed. Valid values are: - abort: Abort the operation on version conflicts. - proceed: Proceed with the operation on version conflicts. | N/A | | default_operator | String | The default operator for query string query: AND or OR. Valid values are: and, AND, or, and OR. | N/A | | df | String | Field to use as default where no field prefix is given in the query string. | N/A | | expand_wildcards | List or String | Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as open,hidden. Valid values are: all, open, closed, hidden, none. Valid values are: - all: Match any index, including hidden ones. - closed: Match closed, non-hidden indexes. - hidden: Match hidden indexes. Must be combined with open, closed, or both. - none: Wildcard expressions are not accepted. - open: Match open, non-hidden indexes. | N/A | | from | Integer | Starting offset. | 0 | | ignore_unavailable | Boolean | If false, the request returns an error if it targets a missing or closed index. | N/A | | lenient | Boolean | If true, format-based query failures (such as providing text to a numeric field) in the query string will be ignored. | N/A | | max_docs | Integer | Maximum number of documents to process. Defaults to all documents. | N/A | | pipeline | String | ID of the pipeline to use to preprocess incoming documents. If the index has a default ingest pipeline specified, then setting the value to _none disables the default ingest pipeline for this request. If a final pipeline is configured it will always run, regardless of the value of this parameter. | N/A | | preference | String | Specifies the node or shard the operation should be performed on. Random by default. | random | | q | String | Query in the Lucene query string syntax. | N/A | | refresh | Boolean or String | If true, OpenSearch refreshes affected shards to make the operation visible to search. Valid values are: - false: Do not refresh the affected shards. - true: Refresh the affected shards immediately. - wait_for: Wait for the changes to become visible before replying. | N/A | | request_cache | Boolean | If true, the request cache is used for this request. | N/A | | requests_per_second | Float | The throttle for this request in sub-requests per second. | 0 | | routing | List or String | A custom value used to route operations to a specific shard. | N/A | | scroll | String | Period to retain the search context for scrolling. | N/A | | scroll_size | Integer | Size of the scroll request that powers the operation. | 100 | | search_timeout | String | Explicit timeout for each search request. | N/A | | search_type | String | The type of the search operation. Available options: query_then_fetch, dfs_query_then_fetch. Valid values are: - dfs_query_then_fetch: Documents are scored using global term and document frequencies across all shards. This is usually slower but more accurate. - query_then_fetch: Documents are scored using local term and document frequencies for the shard. This is usually faster but less accurate. | N/A | | size | Integer | Deprecated, use max_docs instead. | N/A | | slices | Integer or String | The number of slices this task should be divided into. Valid values are: - auto: Automatically determine the number of slices. | N/A | | sort | List | A comma-separated list of : pairs. | N/A | | stats | List | Specific tag of the request for logging and statistical purposes. | N/A | | terminate_after | Integer | Maximum number of documents to collect for each shard. If a query reaches this limit, OpenSearch terminates the query early. OpenSearch collects documents before sorting. Use with caution. OpenSearch applies this parameter to each shard handling the request. When possible, let OpenSearch perform early termination automatically. Avoid specifying this parameter for requests that target data streams with backing indexes across multiple data tiers. | N/A | | timeout | String | Period each update request waits for the following operations: dynamic mapping updates, waiting for active shards. | N/A | | version | Boolean | If true, returns the document version as part of a hit. | N/A | | wait_for_active_shards | Integer or String or NULL or String | The number of shard copies that must be active before proceeding with the operation. Set to all or any positive integer up to the total number of shards in the index (number_of_replicas+1). Valid values are: - all: Wait for all shards to be active. | N/A | | wait_for_completion | Boolean | If true, the request blocks until the operation is complete. | true | Important: update by query 요청에서 _source, _source_includes, _source_excludes를 사용하면 이 설정은 응답뿐 아니라 업데이트 스크립트에서 사용할 수 있는 필드에도 영향을 줘요. _source에서 제외된 필드가 스크립트에서 명시적으로 처리되지 않으면 업데이트 연산 중 문서에서 제거될 수 있습니다. 제외된 필드를 보존하려면 스크립트가 필요에 따라 해당 필드를 읽고 다시 할당하도록 해야 해요.
Request body fields
요청 본문은 선택사항이지만 일반적으로 업데이트할 문서를 지정하는 query와 업데이트 로직을 정의하는 script를 포함해요.
| Field | Data type | Description | | query | Object | The query used to select documents for update. If not specified, the operation updates all documents in the target index. For more information about query types, see Query DSL. | | script | Object | The script to run on each matching document. Contains source (the script code), lang (script language, typically painless), and optional params (parameters passed to the script). The script can access the document via ctx._source and control the operation by setting ctx.op. For more information, see Painless scripting language. | | slice | Object | Manually specify slice ID and maximum slices for parallel processing. Contains id (integer, slice number) and max (integer, total number of slices). Optional. | | max_docs | Integer | Maximum number of documents to process. Optional. | | conflicts | String | What to do when the update by query operation encounters version conflicts. Set to proceed to continue or abort to stop. Can be specified in either the request body or as a query parameter. Optional. |
Script operations
업데이트 스크립트 안에서 ctx.op를 설정해 각 문서에 어떤 일이 일어날지 제어할 수 있어요.
| Operation | Description | | No operation (noop) | Set ctx.op = "noop" to skip updating a document when your script determines no changes are needed. OpenSearch reports skipped documents in the noops counter of the response. | | Delete (delete) | Set ctx.op = "delete" to delete a document based on script logic. OpenSearch reports deleted documents in the deleted counter of the response. | ctx.op를 다른 값으로 설정하면 오류가 발생합니다. ctx._source와 ctx.op 외에 ctx의 다른 필드를 수정해도 오류가 발생해요.
Refreshing shards
refresh 파라미터를 지정하면 요청이 완료된 후 update by query 연산에 관여한 모든 샤드가 리프레시됩니다. 이 동작은 업데이트 요청을 받은 샤드만 리프레시하는 Update API의 refresh 파라미터와 다릅니다. Update by Query API는 refresh 파라미터에 wait_for 값을 지원하지 않아요.
Running update by query asynchronously
update by query 연산을 비동기적으로 실행하려면 wait_for_completion 쿼리 파라미터를 false로 설정하세요. OpenSearch는 사전 점검을 수행하고 요청을 실행한 뒤 진행 상황을 모니터링하거나 연산을 취소하는 데 사용할 수 있는 작업(task) ID를 반환합니다. 비동기로 실행하면 OpenSearch는 작업의 기록을 .tasks/task/${taskId} 위치에 문서로 생성합니다. 작업이 완료된 후에는 작업 문서를 삭제해 OpenSearch가 공간을 회수할 수 있게 하세요.
Waiting for active shards
wait_for_active_shards 파라미터는 요청을 처리하기 전에 몇 개의 샤드 복사본이 활성화되어야 하는지 제어합니다. timeout 파라미터는 각 쓰기 요청이 사용할 수 없는 샤드를 기다리는 시간을 제어해요. 이 파라미터들은 Bulk API에서와 동일하게 동작합니다. Update by Query는 스크롤 검색을 사용하므로 scroll 파라미터로 검색 컨텍스트가 활성 상태로 유지되는 시간을 제어할 수 있어요. 기본 스크롤 시간은 5분입니다.
Throttling update requests
update by query가 업데이트 연산 배치를 발행하는 비율을 제어하려면 requests_per_second를 양의 십진수로 설정하세요. 이렇게 하면 각 배치에 대기 시간이 추가되어 속도를 제한합니다. requests_per_second를 -1로 설정하면 스로틀링을 비활성화해요.
스로틀링은 배치 사이의 대기 시간을 사용해 내부 스크롤 요청에 요청 패딩을 반영한 타임아웃을 줄 수 있게 합니다. 패딩 시간은 배치 크기를 requests_per_second로 나눈 값과 쓰기 소요 시간의 차이입니다. 기본 배치 크기는 1,000이므로 requests_per_second를 500으로 설정하면:
target_time = 1,000 / 500 per second = 2 seconds
wait_time = target_time - write_time = 2 seconds - 0.5 seconds = 1.5 seconds
각 배치는 단일 bulk 요청으로 발행되므로 배치 크기가 크면 OpenSearch가 많은 요청을 만든 뒤 다음 배치를 시작하기 전에 기다립니다. 이로 인해 높은 활동 기간과 유휴 대기가 번갈아 나타나는 고르지 못한 처리 패턴이 생겨요.
Slicing for parallel processing
슬라이싱을 사용하면 여러 스레드에서 업데이트 연산을 병렬로 실행할 수 있어요. 이 방식은 업데이트 연산을 독립적인 세그먼트로 나누어 대규모 업데이트의 성능을 향상시킵니다.
slices를 auto로 설정하면 OpenSearch가 대부분의 인덱스에 적합한 값을 선택할 수 있습니다. 자동 슬라이싱을 사용하거나 수동으로 튜닝할 때 다음 요소를 고려하세요.
- 최적의 쿼리 성능은 슬라이스 수를 샤드 수에 맞출 때 달성됩니다. 다만 샤드가 500개 이상인 인덱스에서는 과도한 병렬화 오버헤드로 인한 성능 저하를 피하려면 더 적은 슬라이스를 사용하세요. 슬라이스를 샤드 수보다 높게 설정하면 일반적으로 효율성이 향상되지 않고 오버헤드만 늘어납니다.
- 업데이트 성능은 슬라이스 수에 따라 사용 가능한 리소스에 걸쳐 선형적으로 증가합니다.
- 쿼리 성능과 업데이트 성능 중 무엇이 런타임을 지배하는지는 업데이트되는 문서와 클러스터의 가용 리소스에 따라 달라집니다.
Example: Updating all documents without changing source
다음 예시 요청은 소스를 수정하지 않고 인덱스의 모든 문서를 업데이트해요. 이는 새 매핑 속성이나 기타 매핑 변경 사항을 적용하는 데 유용합니다.
REST Python
POST /products/_update_by_query?conflicts=proceed
Copy Copy as cURL
response = client.update_by_query(
index = "products",
params = { "conflicts": "proceed" },
body = { "Insert body here" }
)
Copy
Example: Updating documents with a query filter
다음 예시 요청은 10% 할인을 추가해 전자제품만 업데이트해요.
REST Python
POST /products/_update_by_query
{
"query": {
"term": {
"category": "electronics"
}
},
"script": {
"source": "ctx._source.discount = params.discountPercent",
"lang": "painless",
"params": {
"discountPercent": 0.1
}
}
}
Copy Copy as cURL
response = client.update_by_query(
index = "products",
body = {
"query": {
"term": {
"category": "electronics"
}
},
"script": {
"source": "ctx._source.discount = params.discountPercent",
"lang": "painless",
"params": {
"discountPercent": 0.1
}
}
}
)
Copy
Example: Incrementing a field value
다음 예시 요청은 특정 사용자의 모든 제품에 대해 likes 카운터를 증가시켜요.
REST Python
POST /products/_update_by_query
{
"query": {
"term": {
"user_id": "user1"
}
},
"script": {
"source": "ctx._source.likes++",
"lang": "painless"
}
}
Copy Copy as cURL
response = client.update_by_query(
index = "products",
body = {
"query": {
"term": {
"user_id": "user1"
}
},
"script": {
"source": "ctx._source.likes++",
"lang": "painless"
}
}
)
Copy
Example: Conditionally deleting documents
다음 예시 요청은 좋아요가 0개인 재고 없는 제품을 삭제해요.
REST Python
POST /products/_update_by_query
{
"query": {
"bool": {
"must": [
{
"term": {
"in_stock": false
}
},
{
"term": {
"likes": 0
}
}
]
}
},
"script": {
"source": "ctx.op = 'delete'",
"lang": "painless"
}
}
Copy Copy as cURL
response = client.update_by_query(
index = "products",
body = {
"query": {
"bool": {
"must": [
{
"term": {
"in_stock": false
}
},
{
"term": {
"likes": 0
}
}
]
}
},
"script": {
"source": "ctx.op = 'delete'",
"lang": "painless"
}
}
)
Copy
Example: Using noop for conditional updates
다음 예시 요청은 가격이 $100를 초과하는 제품에만 할인을 늘리고, 그 외에는 연산을 수행하지 않아요.
- { ctx._source.discount = 0.15 } else { ctx.op = 'noop' }", "lang": "painless" } } --> REST Python
POST /products/_update_by_query
{
"script": {
"source": "if (ctx._source.price > 100) { ctx._source.discount = 0.15 } else { ctx.op = 'noop' }",
"lang": "painless"
}
}
Copy Copy as cURL
response = client.update_by_query(
index = "products",
body = {
"script": {
"source": "if (ctx._source.price > 100) { ctx._source.discount = 0.15 } else { ctx.op = 'noop' }",
"lang": "painless"
}
}
)
Copy
Example: Updating from multiple indexes
다음 예시 요청은 여러 인덱스에 걸쳐 문서를 업데이트해요.
REST Python
POST /products,inventory/_update_by_query
{
"query": {
"match_all": {}
}
}
Copy Copy as cURL
response = client.update_by_query(
index = "products,inventory",
body = {
"query": {
"match_all": {}
}
}
)
Copy
Example: Using routing for targeted updates
다음 예시 요청은 업데이트 연산을 특정 routing 값을 가진 샤드로 제한해요.
REST Python
POST /products/_update_by_query?routing=user1
{
"query": {
"term": {
"user_id": "user1"
}
},
"script": {
"source": "ctx._source.likes += 5",
"lang": "painless"
}
}
Copy Copy as cURL
response = client.update_by_query(
index = "products",
params = { "routing": "user1" },
body = {
"query": {
"term": {
"user_id": "user1"
}
},
"script": {
"source": "ctx._source.likes += 5",
"lang": "painless"
}
}
)
Copy
Example: Using scroll_size to control batch size
다음 예시 요청은 커스텀 스크롤 배치 크기 100 문서를 사용해요.
REST Python
POST /products/_update_by_query?scroll_size=100
{
"query": {
"range": {
"price": {
"gte": 50
}
}
},
"script": {
"source": "ctx._source.discount = 0.05",
"lang": "painless"
}
}
Copy Copy as cURL
response = client.update_by_query(
index = "products",
params = { "scroll_size": "100" },
body = {
"query": {
"range": {
"price": {
"gte": 50
}
}
},
"script": {
"source": "ctx._source.discount = 0.05",
"lang": "painless"
}
}
)
Copy
Example: Manual slicing for parallel processing
다음 예시 요청은 병렬 처리를 위해 업데이트 연산을 수동으로 두 슬라이스로 나눠요.
REST Python
POST /products/_update_by_query
{
"slice": {
"id": 0,
"max": 2
},
"script": {
"source": "ctx._source.discount = 0.20",
"lang": "painless"
}
}
Copy Copy as cURL
response = client.update_by_query(
index = "products",
body = {
"slice": {
"id": 0,
"max": 2
},
"script": {
"source": "ctx._source.discount = 0.20",
"lang": "painless"
}
}
)
Copy 별도의 요청에서 두 번째 슬라이스를 처리하세요.
REST Python
POST /products/_update_by_query
{
"slice": {
"id": 1,
"max": 2
},
"script": {
"source": "ctx._source.discount = 0.20",
"lang": "painless"
}
}
Copy Copy as cURL
response = client.update_by_query(
index = "products",
body = {
"slice": {
"id": 1,
"max": 2
},
"script": {
"source": "ctx._source.discount = 0.20",
"lang": "painless"
}
}
)
Copy
Example: Automatic slicing
다음 예시 요청은 자동 슬라이싱을 사용해 업데이트 연산을 5개 슬라이스로 병렬화해요.
REST Python
POST /products/_update_by_query?slices=5&refresh=true
{
"script": {
"source": "ctx._source.discount = 0.25",
"lang": "painless"
}
}
Copy Copy as cURL
response = client.update_by_query(
index = "products",
params = { "slices": "5", "refresh": "true" },
body = {
"script": {
"source": "ctx._source.discount = 0.25",
"lang": "painless"
}
}
)
Copy OpenSearch가 최적의 슬라이스 수를 자동으로 결정하게 하려면 slices=auto를 사용하세요.
REST Python
POST /products/_update_by_query?slices=auto
{
"query": {
"term": {
"category": "furniture"
}
},
"script": {
"source": "ctx._source.discount = 0.30",
"lang": "painless"
}
}
Copy Copy as cURL
response = client.update_by_query(
index = "products",
params = { "slices": "auto" },
body = {
"query": {
"term": {
"category": "furniture"
}
},
"script": {
"source": "ctx._source.discount = 0.30",
"lang": "painless"
}
}
)
Copy
Example response
다음 예시 응답은 8개 문서를 업데이트한 성공적인 update by query 연산을 보여줘요.
{
"took": 39,
"timed_out": false,
"total": 8,
"updated": 8,
"deleted": 0,
"batches": 1,
"version_conflicts": 0,
"noops": 0,
"retries": {
"bulk": 0,
"search": 0
},
"throttled_millis": 0,
"requests_per_second": -1.0,
"throttled_until_millis": 0,
"failures": []
}
조건부 noop 연산이 있는 스크립트를 사용하면 응답에 건너뛴 문서 수를 보여주는 noops 카운트가 포함됩니다.
{
"took": 55,
"timed_out": false,
"total": 8,
"updated": 4,
"deleted": 0,
"batches": 1,
"version_conflicts": 0,
"noops": 4,
"retries": {
"bulk": 0,
"search": 0
},
"throttled_millis": 0,
"requests_per_second": -1.0,
"throttled_until_millis": 0,
"failures": []
}
수동 슬라이싱을 사용하면 응답에 처리된 슬라이스를 나타내는 slice_id 필드가 포함됩니다.
{
"took": 12,
"timed_out": false,
"slice_id": 0,
"total": 4,
"updated": 4,
"deleted": 0,
"batches": 1,
"version_conflicts": 0,
"noops": 0,
"retries": {
"bulk": 0,
"search": 0
},
"throttled_millis": 0,
"requests_per_second": -1.0,
"throttled_until_millis": 0,
"failures": []
}
Response body fields
다음 표는 모든 응답 본문 필드를 보여줘요.
| Field | Data type | Description | | took | Integer | The amount of time from the start to the end of the entire operation, in milliseconds. | | timed_out | Boolean | Whether any of the requests executed during the update by query operation timed out. When set to true, successfully completed updates still persist and are not rolled back. | | total | Integer | The total number of documents that were successfully processed. | | updated | Integer | The number of documents that were successfully updated. | | deleted | Integer | The number of documents that were deleted. This occurs when the script sets ctx.op = "delete". | | batches | Integer | The number of scroll batches processed by the update by query operation. | | version_conflicts | Integer | The number of version conflicts encountered by the update by query operation. Occurs when a document changes between the time the snapshot is taken and when the update operation is processed. | | noops | Integer | The number of documents that were ignored because the script set ctx.op = "noop". Unlike delete by query, this field can contain non-zero values when scripts conditionally skip updates. | | retries | Object | The number of retries attempted by the update by query operation. Contains bulk (number of bulk action retries) and search (number of search action retries). | | throttled_millis | Integer | The amount of time the request was throttled to conform to requests_per_second, in milliseconds. | | requests_per_second | Float | The number of requests per second effectively executed during the update by query operation. | | throttled_until_millis | Integer | The amount of time until the next throttled request will be executed, in milliseconds. Always equals 0 in a completed update by query response. This field has meaning only when using the Tasks API to monitor an ongoing operation, where it indicates the next time a throttled request will execute. | | slice_id | Integer | The slice number for this response. Only present when using manual slicing. Indicates which slice of the operation this response represents. | | slices | Array | An array of slice results when using automatic slicing with a specific number. Each element contains the same response fields as the main response, showing the results for that individual slice. | | failures | Array | An array of failures if any unrecoverable errors occurred during the operation. If this array is not empty, the request aborted because of those failures. Update by query is implemented using batches, and any failure causes the entire process to abort, but all failures in the current batch are collected in this array. You can use the conflicts parameter set to proceed to prevent the operation from aborting on version conflicts. |
Managing update by query tasks
wait_for_completion=false로 설정해 update by query 연산을 비동기 실행하면 OpenSearch는 연산을 모니터링, 수정, 취소하는 데 사용할 수 있는 작업 ID를 반환합니다.
Retrieving the status of an update by query operation
update by query 연산의 상태를 조회하려면 Tasks API를 사용하세요.
GET _tasks?detailed=true&actions=*/update/byquery
copy
응답에는 실행 중인 모든 update by query 연산의 상태가 포함됩니다. 특정 작업의 상태를 조회하려면 작업 ID를 사용하세요.
GET _tasks/
copy
응답에는 연산 진행 상황에 대한 상세 정보가 포함됩니다.
{
"nodes": {
"node_id": {
"tasks": {
"task_id": {
"status": {
"total": 1000,
"updated": 450,
"created": 0,
"deleted": 0,
"batches": 5,
"version_conflicts": 0,
"noops": 0,
"retries": 0,
"throttled_millis": 0
}
}
}
}
}
}
total 필드는 update by query 연산이 수행할 것으로 예상하는 총 연산 수를 나타냅니다. updated, deleted, noops 필드를 더하고 그 합을 total 필드와 비교하면 진행 상황을 추정할 수 있어요. 합이 total 필드와 같아지면 연산이 완료된 것입니다.
Changing throttling for a running operation
실행 중인 update by query 연산의 스로틀링을 변경하려면 작업 ID와 함께 Rethrottle Task API를 사용하세요.
POST _update_by_query//_rethrottle?requests_per_second=100
copy
requests_per_second를 양의 십진수 값으로 설정하거나 -1로 설정해 스로틀링을 비활성화하세요. 연산을 더 빠르게 만드는 재스로틀링은 즉시 적용됩니다. 연산을 늦추는 재스로틀링은 스크롤 타임아웃을 방지하기 위해 현재 배치를 완료한 후에 적용됩니다.
Canceling an update by query operation
실행 중인 update by query 연산을 취소하려면 task cancel API를 사용하세요.
POST _tasks//_cancel
copy
취소는 빠르게 이뤄져야 하지만 몇 초가 걸릴 수 있습니다. Tasks API는 취소됐는지 확인하고 스스로 종료할 때까지 update by query 작업을 계속 나열합니다. 슬라이스가 있는 update by query 연산을 취소하면 OpenSearch는 각 하위 요청을 취소해요.
Required permissions
Security 플러그인을 사용한다면 적절한 권한(indices:data/write/update/byquery)을 가지고 있는지 확인하세요.