From 30f79e85764761809e55c1bf20c5324684c95341 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Fri, 11 Jul 2025 10:34:52 +0400 Subject: [PATCH] Add max_docs query parameter to reindex API (#4842) (cherry picked from commit b4c5c332659c4157a8c59714073c2208f93c5c08) # Conflicts: # output/schema/schema.json --- output/openapi/elasticsearch-openapi.json | 10 ++++++++++ .../openapi/elasticsearch-serverless-openapi.json | 10 ++++++++++ output/schema/schema.json | 14 +++++++++++++- output/schema/validation-errors.json | 3 +-- output/typescript/types.ts | 1 + specification/_global/reindex/ReindexRequest.ts | 10 +++++++++- 6 files changed, 44 insertions(+), 4 deletions(-) diff --git a/output/openapi/elasticsearch-openapi.json b/output/openapi/elasticsearch-openapi.json index d690fb8480..5208de94ba 100644 --- a/output/openapi/elasticsearch-openapi.json +++ b/output/openapi/elasticsearch-openapi.json @@ -33383,6 +33383,16 @@ }, "style": "form" }, + { + "in": "query", + "name": "max_docs", + "description": "The maximum number of documents to reindex.\nBy default, all documents are reindexed.\nIf it is a value less then or equal to `scroll_size`, a scroll will not be used to retrieve the results for the operation.\n\nIf `conflicts` is set to `proceed`, the reindex operation could attempt to reindex more documents from the source than `max_docs` until it has successfully indexed `max_docs` documents into the target or it has gone through every document in the source query.", + "deprecated": false, + "schema": { + "type": "number" + }, + "style": "form" + }, { "in": "query", "name": "timeout", diff --git a/output/openapi/elasticsearch-serverless-openapi.json b/output/openapi/elasticsearch-serverless-openapi.json index 5bac6cb2ad..5057b2c456 100644 --- a/output/openapi/elasticsearch-serverless-openapi.json +++ b/output/openapi/elasticsearch-serverless-openapi.json @@ -20562,6 +20562,16 @@ }, "style": "form" }, + { + "in": "query", + "name": "max_docs", + "description": "The maximum number of documents to reindex.\nBy default, all documents are reindexed.\nIf it is a value less then or equal to `scroll_size`, a scroll will not be used to retrieve the results for the operation.\n\nIf `conflicts` is set to `proceed`, the reindex operation could attempt to reindex more documents from the source than `max_docs` until it has successfully indexed `max_docs` documents into the target or it has gone through every document in the source query.", + "deprecated": false, + "schema": { + "type": "number" + }, + "style": "form" + }, { "in": "query", "name": "timeout", diff --git a/output/schema/schema.json b/output/schema/schema.json index 77e3c0c944..dbb1c39a50 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -36207,6 +36207,18 @@ } } }, + { + "description": "The maximum number of documents to reindex.\nBy default, all documents are reindexed.\nIf it is a value less then or equal to `scroll_size`, a scroll will not be used to retrieve the results for the operation.\n\nIf `conflicts` is set to `proceed`, the reindex operation could attempt to reindex more documents from the source than `max_docs` until it has successfully indexed `max_docs` documents into the target or it has gone through every document in the source query.", + "name": "max_docs", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "integer", + "namespace": "_types" + } + } + }, { "description": "The period each indexing waits for automatic index creation, dynamic mapping updates, and waiting for active shards.\nBy default, Elasticsearch waits for at least one minute before failing.\nThe actual wait time could be longer, particularly when multiple waits occur.", "name": "timeout", @@ -36260,7 +36272,7 @@ } } ], - "specLocation": "_global/reindex/ReindexRequest.ts#L27-L309" + "specLocation": "_global/reindex/ReindexRequest.ts#L27-L317" }, { "kind": "response", diff --git a/output/schema/validation-errors.json b/output/schema/validation-errors.json index a75d4984c0..5e28e8dc35 100644 --- a/output/schema/validation-errors.json +++ b/output/schema/validation-errors.json @@ -275,8 +275,7 @@ }, "reindex": { "request": [ - "Request: query parameter 'require_alias' does not exist in the json spec", - "Request: missing json spec query parameter 'max_docs'" + "Request: query parameter 'require_alias' does not exist in the json spec" ], "response": [] }, diff --git a/output/typescript/types.ts b/output/typescript/types.ts index 3c1e6681bb..20b7f8f016 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -1053,6 +1053,7 @@ export interface ReindexRequest extends RequestBase { requests_per_second?: float scroll?: Duration slices?: Slices + max_docs?: integer timeout?: Duration wait_for_active_shards?: WaitForActiveShards wait_for_completion?: boolean diff --git a/specification/_global/reindex/ReindexRequest.ts b/specification/_global/reindex/ReindexRequest.ts index 41ee90bb54..5ad2defbf1 100644 --- a/specification/_global/reindex/ReindexRequest.ts +++ b/specification/_global/reindex/ReindexRequest.ts @@ -19,7 +19,7 @@ import { RequestBase } from '@_types/Base' import { Conflicts, Slices, WaitForActiveShards } from '@_types/common' -import { float, long } from '@_types/Numeric' +import { float, integer, long } from '@_types/Numeric' import { Script } from '@_types/Scripting' import { Duration } from '@_types/Time' import { Destination, Source } from './types' @@ -253,6 +253,14 @@ export interface Request extends RequestBase { * @ext_doc_id slice-scroll */ slices?: Slices + /** + * The maximum number of documents to reindex. + * By default, all documents are reindexed. + * If it is a value less then or equal to `scroll_size`, a scroll will not be used to retrieve the results for the operation. + * + * If `conflicts` is set to `proceed`, the reindex operation could attempt to reindex more documents from the source than `max_docs` until it has successfully indexed `max_docs` documents into the target or it has gone through every document in the source query. + */ + max_docs?: integer /** * The period each indexing waits for automatic index creation, dynamic mapping updates, and waiting for active shards. * By default, Elasticsearch waits for at least one minute before failing.