From 90f22717b1d0c48dd87c6831067e57f134f30c42 Mon Sep 17 00:00:00 2001 From: Przemyslaw Gomulka Date: Mon, 28 Jun 2021 12:03:39 +0200 Subject: [PATCH] [Rest Api Compatibility] Typed TermLookups (#74544) Previously removed in #46943 parsing type field in term lookup is now possible with rest compatible api. The type field is ignored relates main meta issue #51816 relates type removal meta issue #54160 --- rest-api-spec/build.gradle | 2 -- .../src/main/java/org/elasticsearch/indices/TermsLookup.java | 4 ++++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/rest-api-spec/build.gradle b/rest-api-spec/build.gradle index 722ef7f0f4fcc..989e77134cf18 100644 --- a/rest-api-spec/build.gradle +++ b/rest-api-spec/build.gradle @@ -106,8 +106,6 @@ tasks.named("yamlRestCompatTest").configure { 'mtermvectors/11_basic_with_types/Basic tests for multi termvector get', 'mtermvectors/21_deprecated_with_types/Deprecated camel case and _ parameters should fail in Term Vectors query', 'mtermvectors/30_mix_typeless_typeful/mtermvectors without types on an index that has types', - 'search/150_rewrite_on_coordinator/Ensure that we fetch the document only once', //terms_lookup - 'search/171_terms_query_with_types/Terms Query with No.of terms exceeding index.max_terms_count should FAIL', //bulk 'search/260_parameter_validation/test size=-1 is deprecated', //size=-1 change 'search/310_match_bool_prefix/multi_match multiple fields with cutoff_frequency throws exception', //cutoff_frequency 'search/340_type_query/type query', // type_query - probably should behave like match_all diff --git a/server/src/main/java/org/elasticsearch/indices/TermsLookup.java b/server/src/main/java/org/elasticsearch/indices/TermsLookup.java index 53964d11b0d6e..1e2a090f5c2d9 100644 --- a/server/src/main/java/org/elasticsearch/indices/TermsLookup.java +++ b/server/src/main/java/org/elasticsearch/indices/TermsLookup.java @@ -17,6 +17,7 @@ import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; +import org.elasticsearch.core.RestApiVersion; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.query.TermsQueryBuilder; @@ -24,6 +25,7 @@ import java.util.Objects; import static org.elasticsearch.common.xcontent.ConstructingObjectParser.constructorArg; +import static org.elasticsearch.core.RestApiVersion.equalTo; /** * Encapsulates the parameters needed to fetch terms. @@ -107,6 +109,8 @@ public TermsLookup routing(String routing) { PARSER.declareString(constructorArg(), new ParseField("id")); PARSER.declareString(constructorArg(), new ParseField("path")); PARSER.declareString(TermsLookup::routing, new ParseField("routing")); + PARSER.declareString((termLookup,type)-> {}, new ParseField("type") + .forRestApiVersion(equalTo(RestApiVersion.V_7))); } public static TermsLookup parseTermsLookup(XContentParser parser) throws IOException {