Skip to content

Commit 587e5b4

Browse files
authored
[REST Compatible API] Reindex size field (#69037)
For re-index requests, the outer most "size" field was deprecated and renamed to "max_docs" in 7.x (#43373). With this commit, the "size" field will remain available (but still deprecated) through out 8.x when REST API compatibility is requested. relates #51816
1 parent 0d94018 commit 587e5b4

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/feature/FeatureInjector.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import com.fasterxml.jackson.databind.node.TextNode;
1616
import org.elasticsearch.gradle.test.rest.transform.RestTestTransformGlobalSetup;
1717
import org.elasticsearch.gradle.test.rest.transform.RestTestTransformGlobalTeardown;
18+
import org.gradle.api.tasks.Internal;
1819

1920
import javax.annotation.Nullable;
2021
import java.util.Iterator;
@@ -73,6 +74,7 @@ public ObjectNode transformTeardown(@Nullable ObjectNode teardownNodeParent) {
7374
* features: allowed_warnings
7475
* </pre>
7576
*/
77+
@Internal
7678
public abstract String getSkipFeatureName();
7779

7880
private boolean hasFeature(ArrayNode skipParent) {

buildSrc/src/main/java/org/elasticsearch/gradle/test/rest/transform/headers/InjectHeaders.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.elasticsearch.gradle.test.rest.transform.RestTestTransformByParentObject;
1616
import org.elasticsearch.gradle.test.rest.transform.feature.FeatureInjector;
1717
import org.gradle.api.tasks.Input;
18+
import org.gradle.api.tasks.Internal;
1819

1920
import java.util.Map;
2021

@@ -49,6 +50,7 @@ public void transformTest(ObjectNode doNodeParent) {
4950
}
5051

5152
@Override
53+
@Internal
5254
public String getKeyToFind() {
5355
return "do";
5456
}

modules/reindex/build.gradle

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ apply plugin: 'elasticsearch.test-with-dependencies'
1616
apply plugin: 'elasticsearch.jdk-download'
1717
apply plugin: 'elasticsearch.yaml-rest-test'
1818
apply plugin: 'elasticsearch.java-rest-test'
19+
apply plugin: 'elasticsearch.yaml-rest-compat-test'
1920
apply plugin: 'elasticsearch.internal-cluster-test'
2021

2122
esplugin {
@@ -158,3 +159,19 @@ if (Os.isFamily(Os.FAMILY_WINDOWS)) {
158159
}
159160
}
160161
}
162+
163+
tasks.named("yamlRestCompatTest").configure {
164+
systemProperty 'tests.rest.blacklist', [
165+
'reindex/20_validation/reindex without source gives useful error message', /* type in exception message */
166+
'reindex/85_scripting/Reindex all docs with one doc deletion', /*type in a request*/
167+
'delete_by_query/10_basic/Limit by size',
168+
'delete_by_query/10_basic/Response for version conflict \\(seq no powered\\)',
169+
'delete_by_query/20_validation/both max_docs and size fails',
170+
'delete_by_query/20_validation/invalid size fails',
171+
'update_by_query/10_basic/Limit by size',
172+
'update_by_query/10_basic/Response for version conflict \\(seq no powered\\)',
173+
'update_by_query/20_validation/inconsistent max_docs and size fails',
174+
'update_by_query/20_validation/invalid size fails',
175+
'update_by_query/20_validation/update_by_query without source gives useful error message'
176+
].join(',')
177+
}

server/src/main/java/org/elasticsearch/index/reindex/ReindexRequest.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.elasticsearch.common.ParseField;
1616
import org.elasticsearch.common.Strings;
1717
import org.elasticsearch.common.bytes.BytesReference;
18+
import org.elasticsearch.common.compatibility.RestApiCompatibleVersion;
1819
import org.elasticsearch.common.io.stream.StreamInput;
1920
import org.elasticsearch.common.io.stream.StreamOutput;
2021
import org.elasticsearch.common.lucene.uid.Versions;
@@ -346,9 +347,16 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
346347

347348
PARSER.declareField(sourceParser::parse, new ParseField("source"), ObjectParser.ValueType.OBJECT);
348349
PARSER.declareField((p, v, c) -> destParser.parse(p, v.getDestination(), c), new ParseField("dest"), ObjectParser.ValueType.OBJECT);
349-
PARSER.declareInt(ReindexRequest::setMaxDocsValidateIdentical, new ParseField("max_docs"));
350+
351+
PARSER.declareInt(ReindexRequest::setMaxDocsValidateIdentical,
352+
new ParseField("max_docs", "size").withRestApiCompatibilityVersions(RestApiCompatibleVersion.V_7));
353+
354+
PARSER.declareInt(ReindexRequest::setMaxDocsValidateIdentical,
355+
new ParseField("max_docs").withRestApiCompatibilityVersions(RestApiCompatibleVersion.V_8));
350356
// avoid silently accepting an ignored size.
351-
PARSER.declareInt((r,s) -> failOnSizeSpecified(), new ParseField("size"));
357+
PARSER.declareInt((r,s) -> failOnSizeSpecified(),
358+
new ParseField("size").withRestApiCompatibilityVersions(RestApiCompatibleVersion.V_8));
359+
352360
PARSER.declareField((p, v, c) -> v.setScript(Script.parse(p)), new ParseField("script"),
353361
ObjectParser.ValueType.OBJECT);
354362
PARSER.declareString(ReindexRequest::setConflicts, new ParseField("conflicts"));

0 commit comments

Comments
 (0)