diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/RequestConvertersTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/RequestConvertersTests.java index 82ce5f6b9b946..a1946baa3e0e1 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/RequestConvertersTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/RequestConvertersTests.java @@ -427,11 +427,7 @@ public void testReindex() throws IOException { reindexRequest.setDestRouting("=cat"); } if (randomBoolean()) { - if (randomBoolean()) { - reindexRequest.setMaxDocs(randomIntBetween(100, 1000)); - } else { - reindexRequest.setSize(randomIntBetween(100, 1000)); - } + reindexRequest.setMaxDocs(randomIntBetween(100, 1000)); } if (randomBoolean()) { reindexRequest.setAbortOnVersionConflict(false); @@ -479,13 +475,9 @@ public void testUpdateByQuery() throws IOException { expectedParams.put("routing", "=cat"); } if (randomBoolean()) { - int size = randomIntBetween(100, 1000); - if (randomBoolean()) { - updateByQueryRequest.setMaxDocs(size); - } else { - updateByQueryRequest.setSize(size); - } - expectedParams.put("max_docs", Integer.toString(size)); + int maxDocs = randomIntBetween(100, 1000); + updateByQueryRequest.setMaxDocs(maxDocs); + expectedParams.put("max_docs", Integer.toString(maxDocs)); } if (randomBoolean()) { updateByQueryRequest.setAbortOnVersionConflict(false); @@ -528,13 +520,9 @@ public void testDeleteByQuery() throws IOException { expectedParams.put("routing", "=cat"); } if (randomBoolean()) { - int size = randomIntBetween(100, 1000); - if (randomBoolean()) { - deleteByQueryRequest.setMaxDocs(size); - } else { - deleteByQueryRequest.setSize(size); - } - expectedParams.put("max_docs", Integer.toString(size)); + int maxDocs = randomIntBetween(100, 1000); + deleteByQueryRequest.setMaxDocs(maxDocs); + expectedParams.put("max_docs", Integer.toString(maxDocs)); } if (randomBoolean()) { deleteByQueryRequest.setAbortOnVersionConflict(false); diff --git a/docs/reference/migration/migrate_8_0/reindex.asciidoc b/docs/reference/migration/migrate_8_0/reindex.asciidoc index ef4f5aed147ca..912f0f9dbf11b 100644 --- a/docs/reference/migration/migrate_8_0/reindex.asciidoc +++ b/docs/reference/migration/migrate_8_0/reindex.asciidoc @@ -12,4 +12,18 @@ Instead, please specify the index-name without any encoding. [float] ==== Removal of types -The `/{index}/{type}/_delete_by_query` and `/{index}/{type}/_update_by_query` REST endpoints have been removed in favour of `/{index}/_delete_by_query` and `/{index}/_update_by_query`, since indexes no longer contain types, these typed endpoints are obsolete. \ No newline at end of file +The `/{index}/{type}/_delete_by_query` and `/{index}/{type}/_update_by_query` REST endpoints have been removed in favour of `/{index}/_delete_by_query` and `/{index}/_update_by_query`, since indexes no longer contain types, these typed endpoints are obsolete. + +[float] +==== Removal of size parameter + +Previously, a `_reindex` request had two different size specifications in the body: + +- Outer level, determining the maximum number of documents to process +- Inside the `source` element, determining the scroll/batch size. + +The outer level `size` parameter has now been renamed to `max_docs` to +avoid confusion and clarify its semantics. + +Similarly, the `size` parameter has been renamed to `max_docs` for +`_delete_by_query` and `_update_by_query` to keep the 3 interfaces consistent. \ No newline at end of file diff --git a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/AbstractBulkByQueryRestHandler.java b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/AbstractBulkByQueryRestHandler.java index 240ccde350532..fbfd1007a7e02 100644 --- a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/AbstractBulkByQueryRestHandler.java +++ b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/AbstractBulkByQueryRestHandler.java @@ -23,7 +23,6 @@ import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentParser; @@ -53,7 +52,7 @@ protected void parseInternalRequest(Request internal, RestRequest restRequest, SearchRequest searchRequest = internal.getSearchRequest(); try (XContentParser parser = extractRequestSpecificFields(restRequest, bodyConsumers)) { - RestSearchAction.parseSearchRequest(searchRequest, restRequest, parser, size -> setMaxDocsFromSearchSize(internal, size)); + RestSearchAction.parseSearchRequest(searchRequest, restRequest, parser, size -> failOnSizeSpecified()); } searchRequest.source().size(restRequest.paramAsInt("scroll_size", searchRequest.source().size())); @@ -96,8 +95,7 @@ private XContentParser extractRequestSpecificFields(RestRequest restRequest, } } - private void setMaxDocsFromSearchSize(Request request, int size) { - LoggingDeprecationHandler.INSTANCE.usedDeprecatedName("size", "max_docs"); - setMaxDocsValidateIdentical(request, size); + private static void failOnSizeSpecified() { + throw new IllegalArgumentException("invalid parameter [size], use [max_docs] instead"); } } diff --git a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/RoundTripTests.java b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/RoundTripTests.java index d0230eca25126..313d31d84d7b0 100644 --- a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/RoundTripTests.java +++ b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/RoundTripTests.java @@ -107,11 +107,7 @@ private void randomRequest(AbstractBulkByScrollRequest request) { request.getSearchRequest().indices("test"); request.getSearchRequest().source().size(between(1, 1000)); if (randomBoolean()) { - if (randomBoolean()) { - request.setMaxDocs(between(1, Integer.MAX_VALUE)); - } else { - request.setSize(between(1, Integer.MAX_VALUE)); - } + request.setMaxDocs(between(1, Integer.MAX_VALUE)); } request.setAbortOnVersionConflict(random().nextBoolean()); request.setRefresh(rarely()); diff --git a/modules/reindex/src/test/resources/rest-api-spec/test/delete_by_query/10_basic.yml b/modules/reindex/src/test/resources/rest-api-spec/test/delete_by_query/10_basic.yml index c8be7eedd3a2b..1763baebe0277 100644 --- a/modules/reindex/src/test/resources/rest-api-spec/test/delete_by_query/10_basic.yml +++ b/modules/reindex/src/test/resources/rest-api-spec/test/delete_by_query/10_basic.yml @@ -279,52 +279,6 @@ - match: {count: 1} ---- -"Limit by size": - - skip: - version: " - 7.2.99" - reason: "deprecation warnings only emitted on 7.3+" - features: warnings - - - do: - index: - index: twitter - id: 1 - body: { "user": "kimchy" } - - do: - index: - index: twitter - id: 2 - body: { "user": "kimchy" } - - do: - indices.refresh: {} - - - do: - warnings: - - Deprecated field [size] used, expected [max_docs] instead - delete_by_query: - index: twitter - size: 1 - body: - query: - match_all: {} - - - match: {deleted: 1} - - match: {version_conflicts: 0} - - match: {batches: 1} - - match: {failures: []} - - match: {throttled_millis: 0} - - gte: { took: 0 } - - - do: - indices.refresh: {} - - - do: - count: - index: twitter - - - match: {count: 1} - --- "Limit by size pre 7.3": - skip: diff --git a/modules/reindex/src/test/resources/rest-api-spec/test/delete_by_query/20_validation.yml b/modules/reindex/src/test/resources/rest-api-spec/test/delete_by_query/20_validation.yml index 2b1a9514aef19..45de10b370669 100644 --- a/modules/reindex/src/test/resources/rest-api-spec/test/delete_by_query/20_validation.yml +++ b/modules/reindex/src/test/resources/rest-api-spec/test/delete_by_query/20_validation.yml @@ -30,22 +30,6 @@ query: match_all: {} ---- -"invalid size fails": - - do: - index: - index: test - id: 1 - body: { "text": "test" } - - do: - catch: /\[max_docs\] parameter cannot be negative, found \[-4\]/ - delete_by_query: - index: test - size: -4 - body: - query: - match_all: {} - --- "invalid max_docs fails": - skip: @@ -66,27 +50,6 @@ query: match_all: {} ---- -"both max_docs and size fails": - - skip: - version: " - 7.2.99" - reason: "max_docs introduced in 7.3.0" - - - do: - index: - index: test - id: 1 - body: { "text": "test" } - - do: - catch: /\[max_docs\] set to two different values \[4\] and \[5\]/ - delete_by_query: - index: test - size: 4 - max_docs: 5 - body: - query: - match_all: {} - --- "invalid scroll_size fails": - do: diff --git a/modules/reindex/src/test/resources/rest-api-spec/test/reindex/20_validation.yml b/modules/reindex/src/test/resources/rest-api-spec/test/reindex/20_validation.yml index 2c58f122bfeca..44971c49c358a 100644 --- a/modules/reindex/src/test/resources/rest-api-spec/test/reindex/20_validation.yml +++ b/modules/reindex/src/test/resources/rest-api-spec/test/reindex/20_validation.yml @@ -95,21 +95,26 @@ conflicts: cat --- -"invalid size fails": +"specifying size fails": + - skip: + version: " - 7.99.99" + reason: "size supported until 8" + - do: index: - index: test - id: 1 - body: { "text": "test" } + index: test + id: 1 + body: { "text": "test" } + - do: - catch: /\[max_docs\] parameter cannot be negative, found \[-4\]/ + catch: /invalid parameter \[size\], use \[max_docs\] instead/ reindex: body: source: index: test dest: index: dest - size: -4 + size: 1 --- "invalid max_docs in body fails": @@ -153,28 +158,6 @@ dest: index: dest ---- -"inconsistent max_docs and size fails": - - skip: - version: " - 7.2.99" - reason: "max_docs introduced in 7.3.0" - - - do: - index: - index: test - id: 1 - body: { "text": "test" } - - do: - catch: /\[max_docs\] set to two different values \[4\] and \[5\]/ - reindex: - body: - source: - index: test - dest: - index: dest - size: 4 - max_docs: 5 - --- "inconsistent max_docs in body and max_docs in URL fails": - skip: diff --git a/modules/reindex/src/test/resources/rest-api-spec/test/reindex/30_search.yml b/modules/reindex/src/test/resources/rest-api-spec/test/reindex/30_search.yml index 908ab55673c56..709b9c0d17340 100644 --- a/modules/reindex/src/test/resources/rest-api-spec/test/reindex/30_search.yml +++ b/modules/reindex/src/test/resources/rest-api-spec/test/reindex/30_search.yml @@ -31,52 +31,6 @@ index: target - match: { hits.total: 1 } ---- -"Sorting and size combined": - - skip: - version: " - 7.2.99" - reason: "deprecation warnings only emitted on 7.3+" - features: warnings - - - do: - index: - index: test - id: 1 - body: { "order": 1 } - - do: - index: - index: test - id: 2 - body: { "order": 2 } - - do: - indices.refresh: {} - - - do: - warnings: - - Deprecated field [size] used, expected [max_docs] instead - reindex: - refresh: true - body: - size: 1 - source: - index: test - sort: order - dest: - index: target - - - do: - search: - rest_total_hits_as_int: true - index: target - - match: { hits.total: 1 } - - - do: - search: - rest_total_hits_as_int: true - index: target - q: order:1 - - match: { hits.total: 1 } - --- "Sorting and size combined pre 7.3": - skip: diff --git a/modules/reindex/src/test/resources/rest-api-spec/test/reindex/90_remote.yml b/modules/reindex/src/test/resources/rest-api-spec/test/reindex/90_remote.yml index dccf58a51b1ae..8354fc0aaf322 100644 --- a/modules/reindex/src/test/resources/rest-api-spec/test/reindex/90_remote.yml +++ b/modules/reindex/src/test/resources/rest-api-spec/test/reindex/90_remote.yml @@ -217,72 +217,6 @@ metric: search - match: {indices.source.total.search.open_contexts: 0} ---- -"Reindex from remote with size": - - skip: - version: "7.3.0 - " - reason: "7.3 should use max_docs or get deprecation warning" - - - do: - index: - index: source - id: 1 - body: { "text": "test" } - refresh: true - - do: - index: - index: source - id: 2 - body: { "text": "test" } - refresh: true - - # Fetch the http host. We use the host of the master because we know there will always be a master. - - do: - cluster.state: {} - - set: { master_node: master } - - do: - nodes.info: - metric: [ http ] - - is_true: nodes.$master.http.publish_address - - set: {nodes.$master.http.publish_address: host} - - do: - reindex: - refresh: true - body: - size: 1 - source: - remote: - host: http://${host} - index: source - dest: - index: dest - - match: {created: 1} - - match: {updated: 0} - - match: {version_conflicts: 0} - - match: {batches: 1} - - match: {failures: []} - - match: {throttled_millis: 0} - - gte: { took: 0 } - - is_false: task - - is_false: deleted - - - do: - search: - rest_total_hits_as_int: true - index: dest - body: - query: - match: - text: test - - match: {hits.total: 1} - - # Make sure reindex closed all the scroll contexts - - do: - indices.stats: - index: source - metric: search - - match: {indices.source.total.search.open_contexts: 0} - --- "Reindex from remote with max_docs": - skip: diff --git a/modules/reindex/src/test/resources/rest-api-spec/test/update_by_query/10_basic.yml b/modules/reindex/src/test/resources/rest-api-spec/test/update_by_query/10_basic.yml index 67ee48d414c1b..2a3696a4005c7 100644 --- a/modules/reindex/src/test/resources/rest-api-spec/test/update_by_query/10_basic.yml +++ b/modules/reindex/src/test/resources/rest-api-spec/test/update_by_query/10_basic.yml @@ -217,39 +217,6 @@ - match: {failures: []} - gte: { took: 0 } ---- -"Limit by size": - - skip: - version: " - 7.2.99" - reason: "deprecation warnings only emitted on 7.3+" - features: warnings - - - do: - index: - index: twitter - id: 1 - body: { "user": "kimchy" } - - do: - index: - index: twitter - id: 2 - body: { "user": "kimchy" } - - do: - indices.refresh: {} - - - do: - warnings: - - Deprecated field [size] used, expected [max_docs] instead - update_by_query: - index: twitter - size: 1 - - match: {updated: 1} - - match: {version_conflicts: 0} - - match: {batches: 1} - - match: {failures: []} - - match: {throttled_millis: 0} - - gte: { took: 0 } - --- "Limit by size pre 7.3": - skip: diff --git a/modules/reindex/src/test/resources/rest-api-spec/test/update_by_query/20_validation.yml b/modules/reindex/src/test/resources/rest-api-spec/test/update_by_query/20_validation.yml index ddc09fe9d9a61..21644b3932984 100644 --- a/modules/reindex/src/test/resources/rest-api-spec/test/update_by_query/20_validation.yml +++ b/modules/reindex/src/test/resources/rest-api-spec/test/update_by_query/20_validation.yml @@ -11,19 +11,6 @@ index: test conflicts: cat ---- -"invalid size fails": - - do: - index: - index: test - id: 1 - body: { "text": "test" } - - do: - catch: /\[max_docs\] parameter cannot be negative, found \[-4\]/ - update_by_query: - index: test - size: -4 - --- "invalid max_docs in URL fails": - skip: @@ -59,27 +46,6 @@ body: max_docs: -4 ---- -"inconsistent max_docs and size fails": - - skip: - version: " - 7.2.99" - reason: "max_docs introduced in 7.3.0" - - - do: - index: - index: test - id: 1 - body: { "text": "test" } - - do: - catch: /\[max_docs\] set to two different values \[4\] and \[5\]/ - delete_by_query: - index: test - size: 4 - max_docs: 5 - body: - query: - match_all: {} - --- "inconsistent max_docs in body and max_docs in URL fails": - skip: diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/delete_by_query.json b/rest-api-spec/src/main/resources/rest-api-spec/api/delete_by_query.json index 38a8a13fba9fc..d4aadea8b3d80 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/api/delete_by_query.json +++ b/rest-api-spec/src/main/resources/rest-api-spec/api/delete_by_query.json @@ -86,10 +86,6 @@ "type" : "time", "description" : "Explicit timeout for each search request. Defaults to no timeout." }, - "size": { - "type" : "number", - "description" : "Deprecated, please use `max_docs` instead" - }, "max_docs": { "type" : "number", "description" : "Maximum number of documents to process (default: all documents)" diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/update_by_query.json b/rest-api-spec/src/main/resources/rest-api-spec/api/update_by_query.json index 69d36f44140a3..4048b4a55d962 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/api/update_by_query.json +++ b/rest-api-spec/src/main/resources/rest-api-spec/api/update_by_query.json @@ -90,10 +90,6 @@ "type" : "time", "description" : "Explicit timeout for each search request. Defaults to no timeout." }, - "size": { - "type" : "number", - "description" : "Deprecated, please use `max_docs` instead" - }, "max_docs": { "type" : "number", "description" : "Maximum number of documents to process (default: all documents)" diff --git a/server/src/main/java/org/elasticsearch/index/reindex/AbstractBulkByScrollRequest.java b/server/src/main/java/org/elasticsearch/index/reindex/AbstractBulkByScrollRequest.java index c51934c9c04f1..0f27fb4753e9b 100644 --- a/server/src/main/java/org/elasticsearch/index/reindex/AbstractBulkByScrollRequest.java +++ b/server/src/main/java/org/elasticsearch/index/reindex/AbstractBulkByScrollRequest.java @@ -43,11 +43,6 @@ public abstract class AbstractBulkByScrollRequest> extends ActionRequest { public static final int MAX_DOCS_ALL_MATCHES = -1; - /** - * @deprecated please use MAX_DOCS_ALL_MATCHES instead. - */ - @Deprecated - public static final int SIZE_ALL_MATCHES = MAX_DOCS_ALL_MATCHES; public static final TimeValue DEFAULT_SCROLL_TIMEOUT = timeValueMinutes(5); public static final int DEFAULT_SCROLL_SIZE = 1000; @@ -168,27 +163,6 @@ public ActionRequestValidationException validate() { return e; } - /** - * Maximum number of processed documents. Defaults to -1 meaning process all - * documents. - * @deprecated please use getMaxDocs() instead. - */ - @Deprecated - public int getSize() { - return getMaxDocs(); - } - - /** - * Maximum number of processed documents. Defaults to -1 meaning process all - * documents. - * - * @deprecated please use setMaxDocs(int) instead. - */ - @Deprecated - public Self setSize(int size) { - return setMaxDocs(size); - } - /** * Maximum number of processed documents. Defaults to -1 meaning process all * documents. diff --git a/server/src/main/java/org/elasticsearch/index/reindex/ReindexRequest.java b/server/src/main/java/org/elasticsearch/index/reindex/ReindexRequest.java index b5fd41b65db73..743a226c03767 100644 --- a/server/src/main/java/org/elasticsearch/index/reindex/ReindexRequest.java +++ b/server/src/main/java/org/elasticsearch/index/reindex/ReindexRequest.java @@ -379,7 +379,9 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws PARSER.declareField(sourceParser::parse, new ParseField("source"), ObjectParser.ValueType.OBJECT); PARSER.declareField((p, v, c) -> destParser.parse(p, v.getDestination(), c), new ParseField("dest"), ObjectParser.ValueType.OBJECT); - PARSER.declareInt(ReindexRequest::setMaxDocsValidateIdentical, new ParseField("max_docs", "size")); + PARSER.declareInt(ReindexRequest::setMaxDocsValidateIdentical, new ParseField("max_docs")); + // avoid silently accepting an ignored size. + PARSER.declareInt((r,s) -> failOnSizeSpecified(), new ParseField("size")); PARSER.declareField((p, v, c) -> v.setScript(Script.parse(p)), new ParseField("script"), ObjectParser.ValueType.OBJECT); PARSER.declareString(ReindexRequest::setConflicts, new ParseField("conflicts")); @@ -509,4 +511,8 @@ static void setMaxDocsValidateIdentical(AbstractBulkByScrollRequest request, request.setMaxDocs(maxDocs); } } + + private static void failOnSizeSpecified() { + throw new IllegalArgumentException("invalid parameter [size], use [max_docs] instead"); + } } diff --git a/server/src/test/java/org/elasticsearch/index/reindex/AbstractBulkByScrollRequestTestCase.java b/server/src/test/java/org/elasticsearch/index/reindex/AbstractBulkByScrollRequestTestCase.java index 21f250cb1ae79..fdf9840df9e27 100644 --- a/server/src/test/java/org/elasticsearch/index/reindex/AbstractBulkByScrollRequestTestCase.java +++ b/server/src/test/java/org/elasticsearch/index/reindex/AbstractBulkByScrollRequestTestCase.java @@ -42,11 +42,7 @@ public void testForSlice() { original.setRequestsPerSecond( randomBoolean() ? Float.POSITIVE_INFINITY : randomValueOtherThanMany(r -> r < 0, ESTestCase::randomFloat)); if (randomBoolean()) { - if (randomBoolean()) { - original.setMaxDocs(between(0, Integer.MAX_VALUE)); - } else { - original.setSize(between(0, Integer.MAX_VALUE)); - } + original.setMaxDocs(between(0, Integer.MAX_VALUE)); } // it's not important how many slices there are, we just need a number for forSlice