From 74943c43c61d7c36d382402281a6d31f5547b680 Mon Sep 17 00:00:00 2001 From: Xue Zhou <85715413+xuezhou25@users.noreply.github.com> Date: Mon, 29 Nov 2021 19:01:43 +0000 Subject: [PATCH] Rename field_masking_span to span_field_masking (#1606) * Rename field_masking_span to span_field_masking Signed-off-by: Xue Zhou * Update SearchModuleTests.java Signed-off-by: Xue Zhou * Rename field_masking_span to span_field_masking Signed-off-by: Xue Zhou --- .../query/FieldMaskingSpanQueryBuilder.java | 25 ++++++++++++------ .../org/opensearch/search/SearchModule.java | 2 +- .../FieldMaskingSpanQueryBuilderTests.java | 26 ++++++++++++++++++- .../opensearch/search/SearchModuleTests.java | 6 ++--- 4 files changed, 46 insertions(+), 13 deletions(-) diff --git a/server/src/main/java/org/opensearch/index/query/FieldMaskingSpanQueryBuilder.java b/server/src/main/java/org/opensearch/index/query/FieldMaskingSpanQueryBuilder.java index 88d3910d31b..ebc451a4493 100644 --- a/server/src/main/java/org/opensearch/index/query/FieldMaskingSpanQueryBuilder.java +++ b/server/src/main/java/org/opensearch/index/query/FieldMaskingSpanQueryBuilder.java @@ -48,7 +48,7 @@ import java.io.IOException; import java.util.Objects; public class FieldMaskingSpanQueryBuilder extends AbstractQueryBuilder implements SpanQueryBuilder { - public static final String NAME = "field_masking_span"; + public static final ParseField SPAN_FIELD_MASKING_FIELD = new ParseField("span_field_masking", "field_masking_span"); private static final ParseField FIELD_FIELD = new ParseField("field"); private static final ParseField QUERY_FIELD = new ParseField("query"); @@ -105,7 +105,7 @@ public class FieldMaskingSpanQueryBuilder extends AbstractQueryBuilder( - FieldMaskingSpanQueryBuilder.NAME, + FieldMaskingSpanQueryBuilder.SPAN_FIELD_MASKING_FIELD, FieldMaskingSpanQueryBuilder::new, FieldMaskingSpanQueryBuilder::fromXContent ) diff --git a/server/src/test/java/org/opensearch/index/query/FieldMaskingSpanQueryBuilderTests.java b/server/src/test/java/org/opensearch/index/query/FieldMaskingSpanQueryBuilderTests.java index 88ac55fee73..10d4a7918fb 100644 --- a/server/src/test/java/org/opensearch/index/query/FieldMaskingSpanQueryBuilderTests.java +++ b/server/src/test/java/org/opensearch/index/query/FieldMaskingSpanQueryBuilderTests.java @@ -38,6 +38,7 @@ import org.opensearch.test.AbstractQueryTestCase; import java.io.IOException; +import static org.opensearch.index.query.FieldMaskingSpanQueryBuilder.SPAN_FIELD_MASKING_FIELD; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.instanceOf; @@ -73,7 +74,9 @@ public class FieldMaskingSpanQueryBuilderTests extends AbstractQueryTestCase registeredNonDeprecated = module.getNamedXContents() .stream() .filter(e -> e.categoryClass.equals(QueryBuilder.class)) - .filter(e -> e.name.getDeprecatedNames().length == 0) + .filter(e -> e.name.getAllReplacedWith() == null) .map(e -> e.name.getPreferredName()) .collect(toSet()); Set registeredAll = module.getNamedXContents() @@ -422,7 +422,6 @@ public class SearchModuleTests extends OpenSearchTestCase { "constant_score", "dis_max", "exists", - "field_masking_span", "function_score", "fuzzy", "geo_bounding_box", @@ -448,6 +447,7 @@ public class SearchModuleTests extends OpenSearchTestCase { "script_score", "simple_query_string", "span_containing", + "span_field_masking", "span_first", "span_gap", "span_multi", @@ -465,7 +465,7 @@ public class SearchModuleTests extends OpenSearchTestCase { "distance_feature" }; // add here deprecated queries to make sure we log a deprecation warnings when they are used - private static final String[] DEPRECATED_QUERIES = new String[] { "common" }; + private static final String[] DEPRECATED_QUERIES = new String[] { "common", "field_masking_span" }; /** * Dummy test {@link AggregationBuilder} used to test registering aggregation builders.