From 75c0cd06720bddb1afd76c3b37296d5233d2ce20 Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Sun, 17 Dec 2017 14:27:10 -0500 Subject: [PATCH] Move range field mapper back to core This commit moves the range field mapper back to core so that we can remove the compile-time dependency of percolator on mapper-extras which compilcates dependency management for the percolator client JAR, and modules should not be intertwined like this anyway. Relates #27854 --- .../lucene/queries/BinaryDocValuesRangeQuery.java | 1 + .../elasticsearch/index/mapper/BinaryRangeUtil.java | 2 +- .../elasticsearch/index/mapper/RangeFieldMapper.java | 1 + .../org/elasticsearch/indices/IndicesModule.java | 4 ++++ .../BaseRandomBinaryDocValuesRangeQueryTestCase.java | 0 .../queries/BinaryDocValuesRangeQueryTests.java | 0 .../DoubleRandomBinaryDocValuesRangeQueryTests.java | 0 .../FloatRandomBinaryDocValuesRangeQueryTests.java | 0 ...tAddressRandomBinaryDocValuesRangeQueryTests.java | 0 .../IntegerRandomBinaryDocValuesRangeQueryTests.java | 0 .../LongRandomBinaryDocValuesRangeQueryTests.java | 0 .../index/mapper/BinaryRangeUtilTests.java | 0 .../index/mapper/IpRangeFieldMapperTests.java | 12 +++--------- .../index/mapper/RangeFieldMapperTests.java | 3 ++- .../RangeFieldQueryStringQueryBuilderTests.java | 11 ----------- .../index/mapper/RangeFieldTypeTests.java | 2 +- .../index/mapper/MapperExtrasPlugin.java | 3 --- modules/percolator/build.gradle | 2 -- .../resources/rest-api-spec/test/range/10_basic.yml | 0 19 files changed, 13 insertions(+), 28 deletions(-) rename {modules/mapper-extras => core}/src/main/java/org/apache/lucene/queries/BinaryDocValuesRangeQuery.java (99%) rename {modules/mapper-extras => core}/src/main/java/org/elasticsearch/index/mapper/BinaryRangeUtil.java (99%) rename {modules/mapper-extras => core}/src/main/java/org/elasticsearch/index/mapper/RangeFieldMapper.java (99%) rename {modules/mapper-extras => core}/src/test/java/org/apache/lucene/queries/BaseRandomBinaryDocValuesRangeQueryTestCase.java (100%) rename {modules/mapper-extras => core}/src/test/java/org/apache/lucene/queries/BinaryDocValuesRangeQueryTests.java (100%) rename {modules/mapper-extras => core}/src/test/java/org/apache/lucene/queries/DoubleRandomBinaryDocValuesRangeQueryTests.java (100%) rename {modules/mapper-extras => core}/src/test/java/org/apache/lucene/queries/FloatRandomBinaryDocValuesRangeQueryTests.java (100%) rename {modules/mapper-extras => core}/src/test/java/org/apache/lucene/queries/InetAddressRandomBinaryDocValuesRangeQueryTests.java (100%) rename {modules/mapper-extras => core}/src/test/java/org/apache/lucene/queries/IntegerRandomBinaryDocValuesRangeQueryTests.java (100%) rename {modules/mapper-extras => core}/src/test/java/org/apache/lucene/queries/LongRandomBinaryDocValuesRangeQueryTests.java (100%) rename {modules/mapper-extras => core}/src/test/java/org/elasticsearch/index/mapper/BinaryRangeUtilTests.java (100%) rename {modules/mapper-extras => core}/src/test/java/org/elasticsearch/index/mapper/IpRangeFieldMapperTests.java (94%) rename {modules/mapper-extras => core}/src/test/java/org/elasticsearch/index/mapper/RangeFieldMapperTests.java (99%) rename {modules/mapper-extras => core}/src/test/java/org/elasticsearch/index/mapper/RangeFieldQueryStringQueryBuilderTests.java (95%) rename {modules/mapper-extras => core}/src/test/java/org/elasticsearch/index/mapper/RangeFieldTypeTests.java (100%) rename {modules/mapper-extras/src/test => rest-api-spec/src/main}/resources/rest-api-spec/test/range/10_basic.yml (100%) diff --git a/modules/mapper-extras/src/main/java/org/apache/lucene/queries/BinaryDocValuesRangeQuery.java b/core/src/main/java/org/apache/lucene/queries/BinaryDocValuesRangeQuery.java similarity index 99% rename from modules/mapper-extras/src/main/java/org/apache/lucene/queries/BinaryDocValuesRangeQuery.java rename to core/src/main/java/org/apache/lucene/queries/BinaryDocValuesRangeQuery.java index b5caf997495..3cc16ce9320 100644 --- a/modules/mapper-extras/src/main/java/org/apache/lucene/queries/BinaryDocValuesRangeQuery.java +++ b/core/src/main/java/org/apache/lucene/queries/BinaryDocValuesRangeQuery.java @@ -16,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ + package org.apache.lucene.queries; import org.apache.lucene.index.BinaryDocValues; diff --git a/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/BinaryRangeUtil.java b/core/src/main/java/org/elasticsearch/index/mapper/BinaryRangeUtil.java similarity index 99% rename from modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/BinaryRangeUtil.java rename to core/src/main/java/org/elasticsearch/index/mapper/BinaryRangeUtil.java index 384ab24a73b..b58c6deba8c 100644 --- a/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/BinaryRangeUtil.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/BinaryRangeUtil.java @@ -16,9 +16,9 @@ * specific language governing permissions and limitations * under the License. */ + package org.elasticsearch.index.mapper; -import org.apache.lucene.document.HalfFloatPoint; import org.apache.lucene.store.ByteArrayDataOutput; import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.NumericUtils; diff --git a/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/RangeFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/RangeFieldMapper.java similarity index 99% rename from modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/RangeFieldMapper.java rename to core/src/main/java/org/elasticsearch/index/mapper/RangeFieldMapper.java index 46d553a4729..0f0b064e523 100644 --- a/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/RangeFieldMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/RangeFieldMapper.java @@ -16,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ + package org.elasticsearch.index.mapper; import org.apache.lucene.document.DoubleRange; diff --git a/core/src/main/java/org/elasticsearch/indices/IndicesModule.java b/core/src/main/java/org/elasticsearch/indices/IndicesModule.java index f1e52409943..4e1456548ab 100644 --- a/core/src/main/java/org/elasticsearch/indices/IndicesModule.java +++ b/core/src/main/java/org/elasticsearch/indices/IndicesModule.java @@ -43,6 +43,7 @@ import org.elasticsearch.index.mapper.MetadataFieldMapper; import org.elasticsearch.index.mapper.NumberFieldMapper; import org.elasticsearch.index.mapper.ObjectMapper; import org.elasticsearch.index.mapper.ParentFieldMapper; +import org.elasticsearch.index.mapper.RangeFieldMapper; import org.elasticsearch.index.mapper.RoutingFieldMapper; import org.elasticsearch.index.mapper.SeqNoFieldMapper; import org.elasticsearch.index.mapper.SourceFieldMapper; @@ -98,6 +99,9 @@ public class IndicesModule extends AbstractModule { for (NumberFieldMapper.NumberType type : NumberFieldMapper.NumberType.values()) { mappers.put(type.typeName(), new NumberFieldMapper.TypeParser(type)); } + for (RangeFieldMapper.RangeType type : RangeFieldMapper.RangeType.values()) { + mappers.put(type.typeName(), new RangeFieldMapper.TypeParser(type)); + } mappers.put(BooleanFieldMapper.CONTENT_TYPE, new BooleanFieldMapper.TypeParser()); mappers.put(BinaryFieldMapper.CONTENT_TYPE, new BinaryFieldMapper.TypeParser()); mappers.put(DateFieldMapper.CONTENT_TYPE, new DateFieldMapper.TypeParser()); diff --git a/modules/mapper-extras/src/test/java/org/apache/lucene/queries/BaseRandomBinaryDocValuesRangeQueryTestCase.java b/core/src/test/java/org/apache/lucene/queries/BaseRandomBinaryDocValuesRangeQueryTestCase.java similarity index 100% rename from modules/mapper-extras/src/test/java/org/apache/lucene/queries/BaseRandomBinaryDocValuesRangeQueryTestCase.java rename to core/src/test/java/org/apache/lucene/queries/BaseRandomBinaryDocValuesRangeQueryTestCase.java diff --git a/modules/mapper-extras/src/test/java/org/apache/lucene/queries/BinaryDocValuesRangeQueryTests.java b/core/src/test/java/org/apache/lucene/queries/BinaryDocValuesRangeQueryTests.java similarity index 100% rename from modules/mapper-extras/src/test/java/org/apache/lucene/queries/BinaryDocValuesRangeQueryTests.java rename to core/src/test/java/org/apache/lucene/queries/BinaryDocValuesRangeQueryTests.java diff --git a/modules/mapper-extras/src/test/java/org/apache/lucene/queries/DoubleRandomBinaryDocValuesRangeQueryTests.java b/core/src/test/java/org/apache/lucene/queries/DoubleRandomBinaryDocValuesRangeQueryTests.java similarity index 100% rename from modules/mapper-extras/src/test/java/org/apache/lucene/queries/DoubleRandomBinaryDocValuesRangeQueryTests.java rename to core/src/test/java/org/apache/lucene/queries/DoubleRandomBinaryDocValuesRangeQueryTests.java diff --git a/modules/mapper-extras/src/test/java/org/apache/lucene/queries/FloatRandomBinaryDocValuesRangeQueryTests.java b/core/src/test/java/org/apache/lucene/queries/FloatRandomBinaryDocValuesRangeQueryTests.java similarity index 100% rename from modules/mapper-extras/src/test/java/org/apache/lucene/queries/FloatRandomBinaryDocValuesRangeQueryTests.java rename to core/src/test/java/org/apache/lucene/queries/FloatRandomBinaryDocValuesRangeQueryTests.java diff --git a/modules/mapper-extras/src/test/java/org/apache/lucene/queries/InetAddressRandomBinaryDocValuesRangeQueryTests.java b/core/src/test/java/org/apache/lucene/queries/InetAddressRandomBinaryDocValuesRangeQueryTests.java similarity index 100% rename from modules/mapper-extras/src/test/java/org/apache/lucene/queries/InetAddressRandomBinaryDocValuesRangeQueryTests.java rename to core/src/test/java/org/apache/lucene/queries/InetAddressRandomBinaryDocValuesRangeQueryTests.java diff --git a/modules/mapper-extras/src/test/java/org/apache/lucene/queries/IntegerRandomBinaryDocValuesRangeQueryTests.java b/core/src/test/java/org/apache/lucene/queries/IntegerRandomBinaryDocValuesRangeQueryTests.java similarity index 100% rename from modules/mapper-extras/src/test/java/org/apache/lucene/queries/IntegerRandomBinaryDocValuesRangeQueryTests.java rename to core/src/test/java/org/apache/lucene/queries/IntegerRandomBinaryDocValuesRangeQueryTests.java diff --git a/modules/mapper-extras/src/test/java/org/apache/lucene/queries/LongRandomBinaryDocValuesRangeQueryTests.java b/core/src/test/java/org/apache/lucene/queries/LongRandomBinaryDocValuesRangeQueryTests.java similarity index 100% rename from modules/mapper-extras/src/test/java/org/apache/lucene/queries/LongRandomBinaryDocValuesRangeQueryTests.java rename to core/src/test/java/org/apache/lucene/queries/LongRandomBinaryDocValuesRangeQueryTests.java diff --git a/modules/mapper-extras/src/test/java/org/elasticsearch/index/mapper/BinaryRangeUtilTests.java b/core/src/test/java/org/elasticsearch/index/mapper/BinaryRangeUtilTests.java similarity index 100% rename from modules/mapper-extras/src/test/java/org/elasticsearch/index/mapper/BinaryRangeUtilTests.java rename to core/src/test/java/org/elasticsearch/index/mapper/BinaryRangeUtilTests.java diff --git a/modules/mapper-extras/src/test/java/org/elasticsearch/index/mapper/IpRangeFieldMapperTests.java b/core/src/test/java/org/elasticsearch/index/mapper/IpRangeFieldMapperTests.java similarity index 94% rename from modules/mapper-extras/src/test/java/org/elasticsearch/index/mapper/IpRangeFieldMapperTests.java rename to core/src/test/java/org/elasticsearch/index/mapper/IpRangeFieldMapperTests.java index 63ebe7a6cb3..829c05701ff 100644 --- a/modules/mapper-extras/src/test/java/org/elasticsearch/index/mapper/IpRangeFieldMapperTests.java +++ b/core/src/test/java/org/elasticsearch/index/mapper/IpRangeFieldMapperTests.java @@ -18,9 +18,6 @@ */ package org.elasticsearch.index.mapper; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; import org.apache.lucene.index.DocValuesType; import org.apache.lucene.index.IndexableField; import org.elasticsearch.common.compress.CompressedXContent; @@ -29,10 +26,12 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.index.IndexService; -import org.elasticsearch.plugins.Plugin; import org.elasticsearch.test.ESSingleNodeTestCase; import org.junit.Before; +import java.util.HashMap; +import java.util.Map; + import static org.hamcrest.Matchers.containsString; public class IpRangeFieldMapperTests extends ESSingleNodeTestCase { @@ -40,11 +39,6 @@ public class IpRangeFieldMapperTests extends ESSingleNodeTestCase { private IndexService indexService; private DocumentMapperParser parser; - @Override - protected Collection> getPlugins() { - return pluginList(MapperExtrasPlugin.class); - } - @Before public void setup() { indexService = createIndex("test"); diff --git a/modules/mapper-extras/src/test/java/org/elasticsearch/index/mapper/RangeFieldMapperTests.java b/core/src/test/java/org/elasticsearch/index/mapper/RangeFieldMapperTests.java similarity index 99% rename from modules/mapper-extras/src/test/java/org/elasticsearch/index/mapper/RangeFieldMapperTests.java rename to core/src/test/java/org/elasticsearch/index/mapper/RangeFieldMapperTests.java index 0742aeadcb5..eea71525c70 100644 --- a/modules/mapper-extras/src/test/java/org/elasticsearch/index/mapper/RangeFieldMapperTests.java +++ b/core/src/test/java/org/elasticsearch/index/mapper/RangeFieldMapperTests.java @@ -16,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ + package org.elasticsearch.index.mapper; import org.apache.lucene.document.InetAddressPoint; @@ -48,7 +49,7 @@ public class RangeFieldMapperTests extends AbstractNumericFieldMapperTestCase { @Override protected Collection> getPlugins() { - return pluginList(InternalSettingsPlugin.class, MapperExtrasPlugin.class); + return pluginList(InternalSettingsPlugin.class); } private static String FROM_DATE = "2016-10-31"; diff --git a/modules/mapper-extras/src/test/java/org/elasticsearch/index/mapper/RangeFieldQueryStringQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/mapper/RangeFieldQueryStringQueryBuilderTests.java similarity index 95% rename from modules/mapper-extras/src/test/java/org/elasticsearch/index/mapper/RangeFieldQueryStringQueryBuilderTests.java rename to core/src/test/java/org/elasticsearch/index/mapper/RangeFieldQueryStringQueryBuilderTests.java index 654da9ae67b..72195fbd954 100644 --- a/modules/mapper-extras/src/test/java/org/elasticsearch/index/mapper/RangeFieldQueryStringQueryBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/index/mapper/RangeFieldQueryStringQueryBuilderTests.java @@ -21,7 +21,6 @@ package org.elasticsearch.index.mapper; import org.apache.lucene.document.DoubleRange; import org.apache.lucene.document.FloatRange; -import org.apache.lucene.document.InetAddressPoint; import org.apache.lucene.document.InetAddressRange; import org.apache.lucene.document.IntRange; import org.apache.lucene.document.LongRange; @@ -29,22 +28,17 @@ import org.apache.lucene.queries.BinaryDocValuesRangeQuery; import org.apache.lucene.search.IndexOrDocValuesQuery; import org.apache.lucene.search.PointRangeQuery; import org.apache.lucene.search.Query; -import org.apache.lucene.util.BytesRef; import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest; import org.elasticsearch.common.compress.CompressedXContent; import org.elasticsearch.common.joda.DateMathParser; -import org.elasticsearch.common.joda.Joda; import org.elasticsearch.common.network.InetAddresses; import org.elasticsearch.index.query.QueryShardContext; import org.elasticsearch.index.query.QueryStringQueryBuilder; -import org.elasticsearch.plugins.Plugin; import org.elasticsearch.search.internal.SearchContext; import org.elasticsearch.test.AbstractQueryTestCase; import java.io.IOException; import java.net.InetAddress; -import java.util.Collection; -import java.util.Collections; import static org.hamcrest.Matchers.either; import static org.hamcrest.core.IsInstanceOf.instanceOf; @@ -58,11 +52,6 @@ public class RangeFieldQueryStringQueryBuilderTests extends AbstractQueryTestCas private static final String DATE_RANGE_FIELD_NAME = "mapped_date_range"; private static final String IP_RANGE_FIELD_NAME = "mapped_ip_range"; - @Override - protected Collection> getPlugins() { - return Collections.singleton(MapperExtrasPlugin.class); - } - @Override protected void initializeAdditionalMappings(MapperService mapperService) throws IOException { mapperService.merge("_doc", new CompressedXContent(PutMappingRequest.buildFromSimplifiedDef("_doc", diff --git a/modules/mapper-extras/src/test/java/org/elasticsearch/index/mapper/RangeFieldTypeTests.java b/core/src/test/java/org/elasticsearch/index/mapper/RangeFieldTypeTests.java similarity index 100% rename from modules/mapper-extras/src/test/java/org/elasticsearch/index/mapper/RangeFieldTypeTests.java rename to core/src/test/java/org/elasticsearch/index/mapper/RangeFieldTypeTests.java index 81056355596..0c20153675a 100644 --- a/modules/mapper-extras/src/test/java/org/elasticsearch/index/mapper/RangeFieldTypeTests.java +++ b/core/src/test/java/org/elasticsearch/index/mapper/RangeFieldTypeTests.java @@ -16,10 +16,10 @@ * specific language governing permissions and limitations * under the License. */ + package org.elasticsearch.index.mapper; import com.carrotsearch.randomizedtesting.generators.RandomPicks; - import org.apache.lucene.document.DoubleRange; import org.apache.lucene.document.FloatRange; import org.apache.lucene.document.InetAddressPoint; diff --git a/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/MapperExtrasPlugin.java b/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/MapperExtrasPlugin.java index d91d2b28df8..2b249a5fe6e 100644 --- a/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/MapperExtrasPlugin.java +++ b/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/MapperExtrasPlugin.java @@ -33,9 +33,6 @@ public class MapperExtrasPlugin extends Plugin implements MapperPlugin { Map mappers = new LinkedHashMap<>(); mappers.put(ScaledFloatFieldMapper.CONTENT_TYPE, new ScaledFloatFieldMapper.TypeParser()); mappers.put(TokenCountFieldMapper.CONTENT_TYPE, new TokenCountFieldMapper.TypeParser()); - for (RangeFieldMapper.RangeType type : RangeFieldMapper.RangeType.values()) { - mappers.put(type.typeName(), new RangeFieldMapper.TypeParser(type)); - } return Collections.unmodifiableMap(mappers); } diff --git a/modules/percolator/build.gradle b/modules/percolator/build.gradle index 36b93fd4d86..066ae7bb1e0 100644 --- a/modules/percolator/build.gradle +++ b/modules/percolator/build.gradle @@ -24,8 +24,6 @@ esplugin { } dependencies { - // for testing hasChild and hasParent rejections - compile project(path: ':modules:mapper-extras', configuration: 'runtime') testCompile project(path: ':modules:parent-join', configuration: 'runtime') } diff --git a/modules/mapper-extras/src/test/resources/rest-api-spec/test/range/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/range/10_basic.yml similarity index 100% rename from modules/mapper-extras/src/test/resources/rest-api-spec/test/range/10_basic.yml rename to rest-api-spec/src/main/resources/rest-api-spec/test/range/10_basic.yml