From 254d1e3543ab91f8d9a0d5d458410e7a68ffc914 Mon Sep 17 00:00:00 2001 From: Tal Levy Date: Tue, 7 Apr 2020 16:30:58 -0700 Subject: [PATCH] [7.x] Create new `geo` module and migrate geo_shape registration (#53562) (#54924) This commit introduces a new `geo` module that is intended to be contain all the geo-spatial-specific features in server. As a first step, the responsibility of registering the geo_shape field mapper is moved to this module. Co-authored-by: Nicholas Knize --- modules/geo/build.gradle | 23 ++++++ .../java/org/elasticsearch/geo/GeoPlugin.java | 37 +++++++++ .../geo/GeoClientYamlTestSuiteIT.java | 38 ++++++++++ .../java/org/elasticsearch/geo/GeoTests.java | 28 +++++++ .../rest-api-spec/test/geo_shape/10_basic.yml | 59 +++++++++++++++ .../query/RankFeatureQueryBuilderTests.java | 5 +- .../join/aggregations/ChildrenTests.java | 5 +- .../join/aggregations/ParentTests.java | 5 +- .../join/query/HasChildQueryBuilderTests.java | 4 +- .../query/HasParentQueryBuilderTests.java | 4 +- .../join/query/ParentIdQueryBuilderTests.java | 5 +- modules/percolator/build.gradle | 16 +++- .../PercolateQueryBuilderTests.java | 3 +- .../percolator/PercolatorQuerySearchIT.java | 23 ++++-- .../test/search/160_exists_query.yml | 75 ------------------- .../elasticsearch/indices/IndicesModule.java | 3 - .../index/mapper/DocumentParserTests.java | 3 +- .../mapper/FieldFilterMapperPluginTests.java | 4 +- .../mapper/GeoShapeFieldMapperTests.java | 3 +- .../LegacyGeoShapeFieldMapperTests.java | 3 +- .../query/TermsSetQueryBuilderTests.java | 3 +- .../FunctionScoreQueryBuilderTests.java | 3 +- .../search/geo/GeoQueryTests.java | 9 +++ .../test/AbstractBuilderTestCase.java | 3 +- .../elasticsearch/test/ESIntegTestCase.java | 8 ++ .../test/TestGeoShapeFieldMapperPlugin.java | 46 ++++++++++++ x-pack/plugin/enrich/build.gradle | 1 + .../xpack/enrich/BasicEnrichTests.java | 3 +- .../xpack/enrich/EnrichPolicyRunnerTests.java | 14 +++- .../PinnedQueryBuilderTests.java | 2 + x-pack/plugin/spatial/build.gradle | 1 + .../index/query/ShapeQueryBuilderTests.java | 5 +- 32 files changed, 336 insertions(+), 108 deletions(-) create mode 100644 modules/geo/build.gradle create mode 100644 modules/geo/src/main/java/org/elasticsearch/geo/GeoPlugin.java create mode 100644 modules/geo/src/test/java/org/elasticsearch/geo/GeoClientYamlTestSuiteIT.java create mode 100644 modules/geo/src/test/java/org/elasticsearch/geo/GeoTests.java create mode 100644 modules/geo/src/test/resources/rest-api-spec/test/geo_shape/10_basic.yml create mode 100644 test/framework/src/main/java/org/elasticsearch/test/TestGeoShapeFieldMapperPlugin.java diff --git a/modules/geo/build.gradle b/modules/geo/build.gradle new file mode 100644 index 00000000000..7a8ef467aa2 --- /dev/null +++ b/modules/geo/build.gradle @@ -0,0 +1,23 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +esplugin { + description 'Placeholder plugin for geospatial features in ES. only registers geo_shape field mapper for now' + classname 'org.elasticsearch.geo.GeoPlugin' +} diff --git a/modules/geo/src/main/java/org/elasticsearch/geo/GeoPlugin.java b/modules/geo/src/main/java/org/elasticsearch/geo/GeoPlugin.java new file mode 100644 index 00000000000..acb86905510 --- /dev/null +++ b/modules/geo/src/main/java/org/elasticsearch/geo/GeoPlugin.java @@ -0,0 +1,37 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.geo; + +import org.elasticsearch.index.mapper.AbstractGeometryFieldMapper; +import org.elasticsearch.index.mapper.GeoShapeFieldMapper; +import org.elasticsearch.index.mapper.Mapper; +import org.elasticsearch.plugins.MapperPlugin; +import org.elasticsearch.plugins.Plugin; + +import java.util.Collections; +import java.util.Map; + +public class GeoPlugin extends Plugin implements MapperPlugin { + + @Override + public Map getMappers() { + return Collections.singletonMap(GeoShapeFieldMapper.CONTENT_TYPE, new AbstractGeometryFieldMapper.TypeParser()); + } +} diff --git a/modules/geo/src/test/java/org/elasticsearch/geo/GeoClientYamlTestSuiteIT.java b/modules/geo/src/test/java/org/elasticsearch/geo/GeoClientYamlTestSuiteIT.java new file mode 100644 index 00000000000..5835e2114b0 --- /dev/null +++ b/modules/geo/src/test/java/org/elasticsearch/geo/GeoClientYamlTestSuiteIT.java @@ -0,0 +1,38 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.geo; + +import com.carrotsearch.randomizedtesting.annotations.Name; +import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; +import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate; +import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase; + +/** Runs yaml rest tests */ +public class GeoClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase { + + public GeoClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) { + super(testCandidate); + } + + @ParametersFactory + public static Iterable parameters() throws Exception { + return ESClientYamlSuiteTestCase.createParameters(); + } +} diff --git a/modules/geo/src/test/java/org/elasticsearch/geo/GeoTests.java b/modules/geo/src/test/java/org/elasticsearch/geo/GeoTests.java new file mode 100644 index 00000000000..056b4853930 --- /dev/null +++ b/modules/geo/src/test/java/org/elasticsearch/geo/GeoTests.java @@ -0,0 +1,28 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.elasticsearch.geo; + +import org.elasticsearch.test.ESTestCase; + +public class GeoTests extends ESTestCase { + + public void testStub() { + // the build expects unit tests to exist in a module, so here one is. + } +} diff --git a/modules/geo/src/test/resources/rest-api-spec/test/geo_shape/10_basic.yml b/modules/geo/src/test/resources/rest-api-spec/test/geo_shape/10_basic.yml new file mode 100644 index 00000000000..7ddfa5832d4 --- /dev/null +++ b/modules/geo/src/test/resources/rest-api-spec/test/geo_shape/10_basic.yml @@ -0,0 +1,59 @@ +setup: + - do: + indices.create: + index: test + body: + settings: + number_of_replicas: 0 + mappings: + properties: + location: + type: geo_shape + + - do: + index: + index: test + id: 1 + body: + location: "POINT (1.0 1.0)" + + - do: + indices.refresh: {} + +--- +"Test Geo Shape Query": + + - do: + search: + rest_total_hits_as_int: true + body: + query: + bool: + filter: + geo_shape: + location: + shape: + type: Envelope + coordinates: + - [-80.0, 34.0] + - [43, -13.0] + relation: within + + - match: + hits.total: 1 + + - match: + hits.hits.0._id: "1" + +--- +"Test Exists Query on geo_shape field": + - do: + search: + rest_total_hits_as_int: true + index: test + body: + query: + exists: + field: location + + - match: {hits.total: 1} diff --git a/modules/mapper-extras/src/test/java/org/elasticsearch/index/query/RankFeatureQueryBuilderTests.java b/modules/mapper-extras/src/test/java/org/elasticsearch/index/query/RankFeatureQueryBuilderTests.java index 9916af3f0b6..f8d3760bae5 100644 --- a/modules/mapper-extras/src/test/java/org/elasticsearch/index/query/RankFeatureQueryBuilderTests.java +++ b/modules/mapper-extras/src/test/java/org/elasticsearch/index/query/RankFeatureQueryBuilderTests.java @@ -30,11 +30,12 @@ import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.query.RankFeatureQueryBuilder.ScoreFunction; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.test.AbstractQueryTestCase; +import org.elasticsearch.test.TestGeoShapeFieldMapperPlugin; import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; -import java.util.Collections; import java.util.List; import static org.hamcrest.CoreMatchers.instanceOf; @@ -52,7 +53,7 @@ public class RankFeatureQueryBuilderTests extends AbstractQueryTestCase> getPlugins() { - return Collections.singleton(MapperExtrasPlugin.class); + return Arrays.asList(MapperExtrasPlugin.class, TestGeoShapeFieldMapperPlugin.class); } @Override diff --git a/modules/parent-join/src/test/java/org/elasticsearch/join/aggregations/ChildrenTests.java b/modules/parent-join/src/test/java/org/elasticsearch/join/aggregations/ChildrenTests.java index 58d315d2d43..bf016291a16 100644 --- a/modules/parent-join/src/test/java/org/elasticsearch/join/aggregations/ChildrenTests.java +++ b/modules/parent-join/src/test/java/org/elasticsearch/join/aggregations/ChildrenTests.java @@ -22,15 +22,16 @@ package org.elasticsearch.join.aggregations; import org.elasticsearch.join.ParentJoinPlugin; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.search.aggregations.BaseAggregationTestCase; +import org.elasticsearch.test.TestGeoShapeFieldMapperPlugin; +import java.util.Arrays; import java.util.Collection; -import java.util.Collections; public class ChildrenTests extends BaseAggregationTestCase { @Override protected Collection> getPlugins() { - return Collections.singleton(ParentJoinPlugin.class); + return Arrays.asList(ParentJoinPlugin.class, TestGeoShapeFieldMapperPlugin.class); } @Override diff --git a/modules/parent-join/src/test/java/org/elasticsearch/join/aggregations/ParentTests.java b/modules/parent-join/src/test/java/org/elasticsearch/join/aggregations/ParentTests.java index 1df36d28b49..a70af3fd2c2 100644 --- a/modules/parent-join/src/test/java/org/elasticsearch/join/aggregations/ParentTests.java +++ b/modules/parent-join/src/test/java/org/elasticsearch/join/aggregations/ParentTests.java @@ -19,18 +19,19 @@ package org.elasticsearch.join.aggregations; +import java.util.Arrays; import java.util.Collection; -import java.util.Collections; import org.elasticsearch.join.ParentJoinPlugin; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.search.aggregations.BaseAggregationTestCase; +import org.elasticsearch.test.TestGeoShapeFieldMapperPlugin; public class ParentTests extends BaseAggregationTestCase { @Override protected Collection> getPlugins() { - return Collections.singleton(ParentJoinPlugin.class); + return Arrays.asList(ParentJoinPlugin.class, TestGeoShapeFieldMapperPlugin.class); } @Override diff --git a/modules/parent-join/src/test/java/org/elasticsearch/join/query/HasChildQueryBuilderTests.java b/modules/parent-join/src/test/java/org/elasticsearch/join/query/HasChildQueryBuilderTests.java index 6171ee48dba..5e968fed6af 100644 --- a/modules/parent-join/src/test/java/org/elasticsearch/join/query/HasChildQueryBuilderTests.java +++ b/modules/parent-join/src/test/java/org/elasticsearch/join/query/HasChildQueryBuilderTests.java @@ -56,9 +56,11 @@ import org.elasticsearch.plugins.Plugin; import org.elasticsearch.search.sort.FieldSortBuilder; import org.elasticsearch.search.sort.SortOrder; import org.elasticsearch.test.AbstractQueryTestCase; +import org.elasticsearch.test.TestGeoShapeFieldMapperPlugin; import org.elasticsearch.test.VersionUtils; import java.io.IOException; +import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -85,7 +87,7 @@ public class HasChildQueryBuilderTests extends AbstractQueryTestCase> getPlugins() { - return Collections.singletonList(ParentJoinPlugin.class); + return Arrays.asList(ParentJoinPlugin.class, TestGeoShapeFieldMapperPlugin.class); } @Override diff --git a/modules/parent-join/src/test/java/org/elasticsearch/join/query/HasParentQueryBuilderTests.java b/modules/parent-join/src/test/java/org/elasticsearch/join/query/HasParentQueryBuilderTests.java index 1b19fee9703..80d195efb91 100644 --- a/modules/parent-join/src/test/java/org/elasticsearch/join/query/HasParentQueryBuilderTests.java +++ b/modules/parent-join/src/test/java/org/elasticsearch/join/query/HasParentQueryBuilderTests.java @@ -44,9 +44,11 @@ import org.elasticsearch.plugins.Plugin; import org.elasticsearch.search.sort.FieldSortBuilder; import org.elasticsearch.search.sort.SortOrder; import org.elasticsearch.test.AbstractQueryTestCase; +import org.elasticsearch.test.TestGeoShapeFieldMapperPlugin; import org.elasticsearch.test.VersionUtils; import java.io.IOException; +import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -70,7 +72,7 @@ public class HasParentQueryBuilderTests extends AbstractQueryTestCase> getPlugins() { - return Collections.singletonList(ParentJoinPlugin.class); + return Arrays.asList(ParentJoinPlugin.class, TestGeoShapeFieldMapperPlugin.class); } @Override diff --git a/modules/parent-join/src/test/java/org/elasticsearch/join/query/ParentIdQueryBuilderTests.java b/modules/parent-join/src/test/java/org/elasticsearch/join/query/ParentIdQueryBuilderTests.java index 1aa58c0c56b..a98ef07a80d 100644 --- a/modules/parent-join/src/test/java/org/elasticsearch/join/query/ParentIdQueryBuilderTests.java +++ b/modules/parent-join/src/test/java/org/elasticsearch/join/query/ParentIdQueryBuilderTests.java @@ -38,11 +38,12 @@ import org.elasticsearch.index.query.QueryShardException; import org.elasticsearch.join.ParentJoinPlugin; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.test.AbstractQueryTestCase; +import org.elasticsearch.test.TestGeoShapeFieldMapperPlugin; import org.hamcrest.Matchers; import java.io.IOException; +import java.util.Arrays; import java.util.Collection; -import java.util.Collections; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.hamcrest.CoreMatchers.containsString; @@ -61,7 +62,7 @@ public class ParentIdQueryBuilderTests extends AbstractQueryTestCase> getPlugins() { - return Collections.singletonList(ParentJoinPlugin.class); + return Arrays.asList(ParentJoinPlugin.class, TestGeoShapeFieldMapperPlugin.class); } @Override diff --git a/modules/percolator/build.gradle b/modules/percolator/build.gradle index 7aec920d6b0..549d9c7b272 100644 --- a/modules/percolator/build.gradle +++ b/modules/percolator/build.gradle @@ -25,13 +25,27 @@ esplugin { dependencies { testCompile project(path: ':modules:parent-join', configuration: 'runtime') + testCompile project(path: ':modules:geo', configuration: 'runtime') +} + +tasks.named('integTestRunner').configure { + exclude '**/PercolatorQuerySearchIT.class' +} + +tasks.register('internalClusterTest', Test) { + include '**/PercolatorQuerySearchIT.class' +} + +tasks.named('check').configure { + dependsOn 'internalClusterTest' } restResources { restApi { - includeCore '_common', 'indices', 'index', 'search', 'msearch' + includeCore '_common', 'indices', 'index', 'search', 'msearch' } } + dependencyLicenses { // Don't check the client's license. We know it. dependencies = project.configurations.runtime.fileCollection { diff --git a/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolateQueryBuilderTests.java b/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolateQueryBuilderTests.java index bdc17ff8fe9..d1a4d171c48 100644 --- a/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolateQueryBuilderTests.java +++ b/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolateQueryBuilderTests.java @@ -42,6 +42,7 @@ import org.elasticsearch.index.query.Rewriteable; import org.elasticsearch.ingest.RandomDocumentPicks; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.test.AbstractQueryTestCase; +import org.elasticsearch.test.TestGeoShapeFieldMapperPlugin; import org.hamcrest.Matchers; import java.io.IOException; @@ -84,7 +85,7 @@ public class PercolateQueryBuilderTests extends AbstractQueryTestCase> getPlugins() { - return Collections.singleton(PercolatorPlugin.class); + return Arrays.asList(PercolatorPlugin.class, TestGeoShapeFieldMapperPlugin.class); } @Override diff --git a/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorQuerySearchIT.java b/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorQuerySearchIT.java index b32416b69fb..3e7d5611ec4 100644 --- a/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorQuerySearchIT.java +++ b/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorQuerySearchIT.java @@ -31,21 +31,22 @@ import org.elasticsearch.common.unit.DistanceUnit; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentType; +import org.elasticsearch.geo.GeoPlugin; import org.elasticsearch.index.mapper.MapperParsingException; import org.elasticsearch.index.query.MatchPhraseQueryBuilder; import org.elasticsearch.index.query.MultiMatchQueryBuilder; import org.elasticsearch.index.query.Operator; import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.plugins.Plugin; import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder; import org.elasticsearch.search.sort.SortOrder; import org.elasticsearch.test.ESIntegTestCase; - import java.io.IOException; import java.util.Arrays; +import java.util.Collection; import java.util.Collections; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; -import static org.elasticsearch.common.xcontent.XContentFactory.smileBuilder; import static org.elasticsearch.common.xcontent.XContentFactory.yamlBuilder; import static org.elasticsearch.index.query.QueryBuilders.boolQuery; import static org.elasticsearch.index.query.QueryBuilders.commonTermsQuery; @@ -72,6 +73,16 @@ import static org.hamcrest.core.IsNull.notNullValue; public class PercolatorQuerySearchIT extends ESIntegTestCase { + @Override + protected boolean addMockGeoShapeFieldMapper() { + return false; + } + + @Override + protected Collection> nodePlugins() { + return Arrays.asList(PercolatorPlugin.class, GeoPlugin.class); + } + public void testPercolatorQuery() throws Exception { assertAcked(client().admin().indices().prepareCreate("test") .addMapping("type", "id", "type=keyword", "field1", "type=keyword", "field2", "type=keyword", "query", "type=percolator") @@ -318,8 +329,8 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase { .must(matchQuery("field2", "value"))).endObject()).get(); client().prepareIndex("test", "type", "4").setSource("{\"id\": \"4\"}", XContentType.JSON).get(); - client().prepareIndex("test", "type", "5").setSource("id", "5", "field1", "value").get(); - client().prepareIndex("test", "type", "6").setSource("id", "6", "field1", "value", "field2", "value").get(); + client().prepareIndex("test", "type", "5").setSource(XContentType.JSON, "id", "5", "field1", "value").get(); + client().prepareIndex("test", "type", "6").setSource(XContentType.JSON, "id", "6", "field1", "value", "field2", "value").get(); client().admin().indices().prepareRefresh().get(); logger.info("percolating empty doc"); @@ -850,7 +861,7 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase { BytesReference.bytes(yamlBuilder().startObject().field("field1", "c").endObject()), XContentType.YAML))) .add(client().prepareSearch("test") .setQuery(new PercolateQueryBuilder("query", - BytesReference.bytes(smileBuilder().startObject().field("field1", "b c").endObject()), XContentType.SMILE))) + BytesReference.bytes(jsonBuilder().startObject().field("field1", "b c").endObject()), XContentType.JSON))) .add(client().prepareSearch("test") .setQuery(new PercolateQueryBuilder("query", BytesReference.bytes(jsonBuilder().startObject().field("field1", "d").endObject()), XContentType.JSON))) @@ -967,7 +978,7 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase { BytesReference.bytes(jsonBuilder().startObject().field("d", "2020-02-01T15:00:00.000+11:00").endObject()), XContentType.JSON)).get(); assertEquals(1, response.getHits().getTotalHits().value); - + response = client().prepareSearch("test").setQuery(new PercolateQueryBuilder("q", BytesReference.bytes(jsonBuilder().startObject().field("d", "2020-02-01T15:00:00.000+11:00").endObject()), XContentType.JSON)).addSort("_doc", SortOrder.ASC).get(); diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/search/160_exists_query.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/search/160_exists_query.yml index d94e86bb6c5..306450676b3 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/search/160_exists_query.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/search/160_exists_query.yml @@ -18,8 +18,6 @@ setup: type: date geo_point: type: geo_point - geo_shape: - type: geo_shape ip: type: ip keyword: @@ -59,9 +57,6 @@ setup: boolean: true date: "2017-01-01" geo_point: [0.0, 20.0] - geo_shape: - type: "point" - coordinates: [0.0, 20.0] ip: "192.168.0.1" keyword: "foo" byte: 1 @@ -87,9 +82,6 @@ setup: boolean: false date: "2017-01-01" geo_point: [0.0, 20.0] - geo_shape: - type: "point" - coordinates: [0.0, 20.0] ip: "192.168.0.1" keyword: "foo" byte: 1 @@ -115,9 +107,6 @@ setup: boolean: true date: "2017-01-01" geo_point: [0.0, 20.0] - geo_shape: - type: "point" - coordinates: [0.0, 20.0] ip: "192.168.0.1" keyword: "foo" byte: 1 @@ -157,8 +146,6 @@ setup: geo_point: type: geo_point doc_values: false - geo_shape: - type: geo_shape ip: type: ip doc_values: false @@ -210,9 +197,6 @@ setup: boolean: true date: "2017-01-01" geo_point: [0.0, 20.0] - geo_shape: - type: "point" - coordinates: [0.0, 20.0] ip: "192.168.0.1" keyword: "foo" byte: 1 @@ -238,9 +222,6 @@ setup: boolean: false date: "2017-01-01" geo_point: [0.0, 20.0] - geo_shape: - type: "point" - coordinates: [0.0, 20.0] ip: "192.168.0.1" keyword: "foo" byte: 1 @@ -266,9 +247,6 @@ setup: boolean: true date: "2017-01-01" geo_point: [0.0, 20.0] - geo_shape: - type: "point" - coordinates: [0.0, 20.0] ip: "192.168.0.1" keyword: "foo" byte: 1 @@ -318,8 +296,6 @@ setup: type: date geo_point: type: geo_point - geo_shape: - type: geo_shape ip: type: ip keyword: @@ -404,19 +380,6 @@ setup: - match: {hits.total: 3} ---- -"Test exists query on mapped geo_shape field": - - do: - search: - rest_total_hits_as_int: true - index: test - body: - query: - exists: - field: geo_shape - - - match: {hits.total: 3} - --- "Test exists query on mapped ip field": - do: @@ -724,19 +687,6 @@ setup: - match: {hits.total: 0} ---- -"Test exists query on unmapped geo_shape field": - - do: - search: - rest_total_hits_as_int: true - index: test-unmapped - body: - query: - exists: - field: geo_shape - - - match: {hits.total: 0} - --- "Test exists query on unmapped ip field": - do: @@ -945,19 +895,6 @@ setup: - match: {hits.total: 0} ---- -"Test exists query on geo_shape field in empty index": - - do: - search: - rest_total_hits_as_int: true - index: test-empty - body: - query: - exists: - field: geo_shape - - - match: {hits.total: 0} - --- "Test exists query on ip field in empty index": - do: @@ -1166,18 +1103,6 @@ setup: - match: {hits.total: 3} ---- -"Test exists query on mapped geo_shape field with no doc values": - - do: - search: - rest_total_hits_as_int: true - index: test-no-dv - body: - query: - exists: - field: geo_shape - - - match: {hits.total: 3} --- "Test exists query on mapped ip field with no doc values": diff --git a/server/src/main/java/org/elasticsearch/indices/IndicesModule.java b/server/src/main/java/org/elasticsearch/indices/IndicesModule.java index dc332a13669..583a856da41 100644 --- a/server/src/main/java/org/elasticsearch/indices/IndicesModule.java +++ b/server/src/main/java/org/elasticsearch/indices/IndicesModule.java @@ -31,7 +31,6 @@ import org.elasticsearch.common.io.stream.NamedWriteableRegistry.Entry; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.engine.EngineFactory; -import org.elasticsearch.index.mapper.AbstractGeometryFieldMapper; import org.elasticsearch.index.mapper.BinaryFieldMapper; import org.elasticsearch.index.mapper.BooleanFieldMapper; import org.elasticsearch.index.mapper.CompletionFieldMapper; @@ -39,7 +38,6 @@ import org.elasticsearch.index.mapper.DateFieldMapper; import org.elasticsearch.index.mapper.FieldAliasMapper; import org.elasticsearch.index.mapper.FieldNamesFieldMapper; import org.elasticsearch.index.mapper.GeoPointFieldMapper; -import org.elasticsearch.index.mapper.GeoShapeFieldMapper; import org.elasticsearch.index.mapper.IdFieldMapper; import org.elasticsearch.index.mapper.IgnoredFieldMapper; import org.elasticsearch.index.mapper.IndexFieldMapper; @@ -139,7 +137,6 @@ public class IndicesModule extends AbstractModule { mappers.put(CompletionFieldMapper.CONTENT_TYPE, new CompletionFieldMapper.TypeParser()); mappers.put(FieldAliasMapper.CONTENT_TYPE, new FieldAliasMapper.TypeParser()); mappers.put(GeoPointFieldMapper.CONTENT_TYPE, new GeoPointFieldMapper.TypeParser()); - mappers.put(GeoShapeFieldMapper.CONTENT_TYPE, new AbstractGeometryFieldMapper.TypeParser()); for (MapperPlugin mapperPlugin : mapperPlugins) { for (Map.Entry entry : mapperPlugin.getMappers().entrySet()) { diff --git a/server/src/test/java/org/elasticsearch/index/mapper/DocumentParserTests.java b/server/src/test/java/org/elasticsearch/index/mapper/DocumentParserTests.java index bf38cf93b8f..ebd89f993c4 100644 --- a/server/src/test/java/org/elasticsearch/index/mapper/DocumentParserTests.java +++ b/server/src/test/java/org/elasticsearch/index/mapper/DocumentParserTests.java @@ -36,6 +36,7 @@ import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.mapper.ParseContext.Document; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.test.ESSingleNodeTestCase; +import org.elasticsearch.test.TestGeoShapeFieldMapperPlugin; import org.elasticsearch.test.InternalSettingsPlugin; import java.io.IOException; @@ -61,7 +62,7 @@ public class DocumentParserTests extends ESSingleNodeTestCase { @Override protected Collection> getPlugins() { - return pluginList(InternalSettingsPlugin.class); + return pluginList(InternalSettingsPlugin.class, TestGeoShapeFieldMapperPlugin.class); } public void testFieldDisabled() throws Exception { diff --git a/server/src/test/java/org/elasticsearch/index/mapper/FieldFilterMapperPluginTests.java b/server/src/test/java/org/elasticsearch/index/mapper/FieldFilterMapperPluginTests.java index 9384024d2e2..a68d20dc595 100644 --- a/server/src/test/java/org/elasticsearch/index/mapper/FieldFilterMapperPluginTests.java +++ b/server/src/test/java/org/elasticsearch/index/mapper/FieldFilterMapperPluginTests.java @@ -33,12 +33,12 @@ import org.elasticsearch.indices.IndicesModule; import org.elasticsearch.plugins.MapperPlugin; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.test.ESSingleNodeTestCase; +import org.elasticsearch.test.TestGeoShapeFieldMapperPlugin; import org.junit.Before; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -54,7 +54,7 @@ public class FieldFilterMapperPluginTests extends ESSingleNodeTestCase { @Override protected Collection> getPlugins() { - return Collections.singleton(FieldFilterPlugin.class); + return Arrays.asList(FieldFilterPlugin.class, TestGeoShapeFieldMapperPlugin.class); } @Before diff --git a/server/src/test/java/org/elasticsearch/index/mapper/GeoShapeFieldMapperTests.java b/server/src/test/java/org/elasticsearch/index/mapper/GeoShapeFieldMapperTests.java index e14d04eb7d6..00496acf1d0 100644 --- a/server/src/test/java/org/elasticsearch/index/mapper/GeoShapeFieldMapperTests.java +++ b/server/src/test/java/org/elasticsearch/index/mapper/GeoShapeFieldMapperTests.java @@ -28,6 +28,7 @@ import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.test.ESSingleNodeTestCase; import org.elasticsearch.test.InternalSettingsPlugin; +import org.elasticsearch.test.TestGeoShapeFieldMapperPlugin; import java.io.IOException; import java.util.Collection; @@ -42,7 +43,7 @@ public class GeoShapeFieldMapperTests extends ESSingleNodeTestCase { @Override protected Collection> getPlugins() { - return pluginList(InternalSettingsPlugin.class); + return pluginList(InternalSettingsPlugin.class, TestGeoShapeFieldMapperPlugin.class); } public void testDefaultConfiguration() throws IOException { diff --git a/server/src/test/java/org/elasticsearch/index/mapper/LegacyGeoShapeFieldMapperTests.java b/server/src/test/java/org/elasticsearch/index/mapper/LegacyGeoShapeFieldMapperTests.java index aaabf3f9edb..9236447b2f1 100644 --- a/server/src/test/java/org/elasticsearch/index/mapper/LegacyGeoShapeFieldMapperTests.java +++ b/server/src/test/java/org/elasticsearch/index/mapper/LegacyGeoShapeFieldMapperTests.java @@ -39,6 +39,7 @@ import org.elasticsearch.index.query.QueryShardContext; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.test.ESSingleNodeTestCase; import org.elasticsearch.test.InternalSettingsPlugin; +import org.elasticsearch.test.TestGeoShapeFieldMapperPlugin; import java.io.IOException; import java.util.Collection; @@ -56,7 +57,7 @@ public class LegacyGeoShapeFieldMapperTests extends ESSingleNodeTestCase { @Override protected Collection> getPlugins() { - return pluginList(InternalSettingsPlugin.class); + return pluginList(InternalSettingsPlugin.class, TestGeoShapeFieldMapperPlugin.class); } public void testDefaultConfiguration() throws IOException { diff --git a/server/src/test/java/org/elasticsearch/index/query/TermsSetQueryBuilderTests.java b/server/src/test/java/org/elasticsearch/index/query/TermsSetQueryBuilderTests.java index b294468d4ee..b7d95e23a24 100644 --- a/server/src/test/java/org/elasticsearch/index/query/TermsSetQueryBuilderTests.java +++ b/server/src/test/java/org/elasticsearch/index/query/TermsSetQueryBuilderTests.java @@ -49,6 +49,7 @@ import org.elasticsearch.script.MockScriptPlugin; import org.elasticsearch.script.Script; import org.elasticsearch.script.ScriptType; import org.elasticsearch.test.AbstractQueryTestCase; +import org.elasticsearch.test.TestGeoShapeFieldMapperPlugin; import org.elasticsearch.test.rest.yaml.ObjectPath; import java.io.IOException; @@ -71,7 +72,7 @@ public class TermsSetQueryBuilderTests extends AbstractQueryTestCase> getPlugins() { - return Collections.singleton(CustomScriptPlugin.class); + return Arrays.asList(CustomScriptPlugin.class, TestGeoShapeFieldMapperPlugin.class); } @Override diff --git a/server/src/test/java/org/elasticsearch/index/query/functionscore/FunctionScoreQueryBuilderTests.java b/server/src/test/java/org/elasticsearch/index/query/functionscore/FunctionScoreQueryBuilderTests.java index f35cc6ba8f5..b69e7aae67b 100644 --- a/server/src/test/java/org/elasticsearch/index/query/functionscore/FunctionScoreQueryBuilderTests.java +++ b/server/src/test/java/org/elasticsearch/index/query/functionscore/FunctionScoreQueryBuilderTests.java @@ -53,6 +53,7 @@ import org.elasticsearch.script.Script; import org.elasticsearch.script.ScriptType; import org.elasticsearch.search.MultiValueMode; import org.elasticsearch.test.AbstractQueryTestCase; +import org.elasticsearch.test.TestGeoShapeFieldMapperPlugin; import org.hamcrest.Matcher; import org.joda.time.DateTime; import org.joda.time.DateTimeZone; @@ -88,7 +89,7 @@ public class FunctionScoreQueryBuilderTests extends AbstractQueryTestCase> getPlugins() { - return Collections.singleton(TestPlugin.class); + return Arrays.asList(TestPlugin.class, TestGeoShapeFieldMapperPlugin.class); } @Override diff --git a/server/src/test/java/org/elasticsearch/search/geo/GeoQueryTests.java b/server/src/test/java/org/elasticsearch/search/geo/GeoQueryTests.java index f08d26ae76a..467f40be9df 100644 --- a/server/src/test/java/org/elasticsearch/search/geo/GeoQueryTests.java +++ b/server/src/test/java/org/elasticsearch/search/geo/GeoQueryTests.java @@ -36,10 +36,15 @@ import org.elasticsearch.geometry.Geometry; import org.elasticsearch.geometry.Rectangle; import org.elasticsearch.index.query.GeoShapeQueryBuilder; import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.plugins.Plugin; import org.elasticsearch.search.SearchHits; import org.elasticsearch.test.ESSingleNodeTestCase; +import org.elasticsearch.test.TestGeoShapeFieldMapperPlugin; import org.locationtech.jts.geom.Coordinate; +import java.util.Collection; +import java.util.Collections; + import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount; @@ -50,6 +55,10 @@ import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.nullValue; public abstract class GeoQueryTests extends ESSingleNodeTestCase { + @Override + protected Collection> getPlugins() { + return Collections.singleton(TestGeoShapeFieldMapperPlugin.class); + } protected abstract XContentBuilder createTypedMapping() throws Exception; diff --git a/test/framework/src/main/java/org/elasticsearch/test/AbstractBuilderTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/AbstractBuilderTestCase.java index 32d932cd560..25445c8f5fb 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/AbstractBuilderTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/AbstractBuilderTestCase.java @@ -148,8 +148,9 @@ public abstract class AbstractBuilderTestCase extends ESTestCase { return index; } + @SuppressWarnings("deprecation") // dependencies in server for geo_shape field should be decoupled protected Collection> getPlugins() { - return Collections.emptyList(); + return Collections.singletonList(TestGeoShapeFieldMapperPlugin.class); } protected void initializeAdditionalMappings(MapperService mapperService) throws IOException { diff --git a/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java index aef67ded489..e03f35c865d 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java @@ -1997,6 +1997,11 @@ public abstract class ESIntegTestCase extends ESTestCase { return true; } + /** Returns {@code true} iff this test cluster should use a dummy geo_shape field mapper */ + protected boolean addMockGeoShapeFieldMapper() { + return true; + } + /** * Returns a function that allows to wrap / filter all clients that are exposed by the test cluster. This is useful * for debugging or request / response pre and post processing. It also allows to intercept all calls done by the test @@ -2039,6 +2044,9 @@ public abstract class ESIntegTestCase extends ESTestCase { mocks.add(TestSeedPlugin.class); mocks.add(AssertActionNamePlugin.class); mocks.add(MockScriptService.TestPlugin.class); + if (addMockGeoShapeFieldMapper()) { + mocks.add(TestGeoShapeFieldMapperPlugin.class); + } return Collections.unmodifiableList(mocks); } diff --git a/test/framework/src/main/java/org/elasticsearch/test/TestGeoShapeFieldMapperPlugin.java b/test/framework/src/main/java/org/elasticsearch/test/TestGeoShapeFieldMapperPlugin.java new file mode 100644 index 00000000000..a269ad437a9 --- /dev/null +++ b/test/framework/src/main/java/org/elasticsearch/test/TestGeoShapeFieldMapperPlugin.java @@ -0,0 +1,46 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.elasticsearch.test; + +import org.elasticsearch.index.mapper.AbstractGeometryFieldMapper; +import org.elasticsearch.index.mapper.GeoShapeFieldMapper; +import org.elasticsearch.index.mapper.Mapper; +import org.elasticsearch.plugins.MapperPlugin; +import org.elasticsearch.plugins.Plugin; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * Some tests depend on the {@link org.elasticsearch.index.mapper.GeoShapeFieldMapper}. + * This mapper is registered in the spatial-extras module, but used in many integration + * tests in server code. The goal is to migrate all of the spatial/geo pieces to the spatial-extras + * module such that no tests in server depend on this test plugin + */ +@Deprecated +public class TestGeoShapeFieldMapperPlugin extends Plugin implements MapperPlugin { + + @Override + public Map getMappers() { + Map mappers = new LinkedHashMap<>(); + mappers.put(GeoShapeFieldMapper.CONTENT_TYPE, new AbstractGeometryFieldMapper.TypeParser()); + return Collections.unmodifiableMap(mappers); + } +} diff --git a/x-pack/plugin/enrich/build.gradle b/x-pack/plugin/enrich/build.gradle index 12ca16115f8..95ed9b170b7 100644 --- a/x-pack/plugin/enrich/build.gradle +++ b/x-pack/plugin/enrich/build.gradle @@ -14,6 +14,7 @@ dependencies { testCompile project(path: xpackModule('core'), configuration: 'testArtifacts') testCompile project(path: ':modules:ingest-common') testCompile project(path: ':modules:lang-mustache') + testCompile project(path: ':modules:geo') testCompile project(path: xpackModule('monitoring'), configuration: 'testArtifacts') } diff --git a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/BasicEnrichTests.java b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/BasicEnrichTests.java index 3d0e30198ba..e31596b90ad 100644 --- a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/BasicEnrichTests.java +++ b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/BasicEnrichTests.java @@ -19,6 +19,7 @@ import org.elasticsearch.action.ingest.PutPipelineRequest; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.xcontent.XContentType; +import org.elasticsearch.geo.GeoPlugin; import org.elasticsearch.index.reindex.ReindexPlugin; import org.elasticsearch.ingest.common.IngestCommonPlugin; import org.elasticsearch.plugins.Plugin; @@ -54,7 +55,7 @@ public class BasicEnrichTests extends ESSingleNodeTestCase { @Override protected Collection> getPlugins() { - return Arrays.asList(LocalStateEnrich.class, ReindexPlugin.class, IngestCommonPlugin.class, MustachePlugin.class); + return Arrays.asList(LocalStateEnrich.class, ReindexPlugin.class, IngestCommonPlugin.class, MustachePlugin.class, GeoPlugin.class); } @Override diff --git a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichPolicyRunnerTests.java b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichPolicyRunnerTests.java index 4ac295c0995..abe07525794 100644 --- a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichPolicyRunnerTests.java +++ b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichPolicyRunnerTests.java @@ -29,6 +29,7 @@ import org.elasticsearch.action.admin.indices.segments.IndexShardSegments; import org.elasticsearch.action.admin.indices.segments.IndicesSegmentResponse; import org.elasticsearch.action.admin.indices.segments.IndicesSegmentsRequest; import org.elasticsearch.action.admin.indices.segments.ShardSegments; +import org.elasticsearch.geo.GeoPlugin; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.index.IndexResponse; import org.elasticsearch.action.search.SearchRequest; @@ -62,6 +63,17 @@ import org.elasticsearch.xpack.core.enrich.action.ExecuteEnrichPolicyStatus; import org.junit.AfterClass; import org.junit.BeforeClass; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Consumer; + import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.instanceOf; @@ -72,7 +84,7 @@ public class EnrichPolicyRunnerTests extends ESSingleNodeTestCase { @Override protected Collection> getPlugins() { - return Arrays.asList(ReindexPlugin.class, IngestCommonPlugin.class); + return Arrays.asList(ReindexPlugin.class, IngestCommonPlugin.class, GeoPlugin.class); } private static ThreadPool testThreadPool; diff --git a/x-pack/plugin/search-business-rules/src/test/java/org/elasticsearch/xpack/searchbusinessrules/PinnedQueryBuilderTests.java b/x-pack/plugin/search-business-rules/src/test/java/org/elasticsearch/xpack/searchbusinessrules/PinnedQueryBuilderTests.java index d9514ce3547..1782ec93d76 100644 --- a/x-pack/plugin/search-business-rules/src/test/java/org/elasticsearch/xpack/searchbusinessrules/PinnedQueryBuilderTests.java +++ b/x-pack/plugin/search-business-rules/src/test/java/org/elasticsearch/xpack/searchbusinessrules/PinnedQueryBuilderTests.java @@ -22,6 +22,7 @@ import org.elasticsearch.index.query.QueryShardContext; import org.elasticsearch.index.query.TermQueryBuilder; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.test.AbstractQueryTestCase; +import org.elasticsearch.test.TestGeoShapeFieldMapperPlugin; import java.io.IOException; import java.util.ArrayList; @@ -104,6 +105,7 @@ public class PinnedQueryBuilderTests extends AbstractQueryTestCase> getPlugins() { List> classpathPlugins = new ArrayList<>(); classpathPlugins.add(SearchBusinessRules.class); + classpathPlugins.add(TestGeoShapeFieldMapperPlugin.class); return classpathPlugins; } diff --git a/x-pack/plugin/spatial/build.gradle b/x-pack/plugin/spatial/build.gradle index aa5f3ff9328..7daf9240cd5 100644 --- a/x-pack/plugin/spatial/build.gradle +++ b/x-pack/plugin/spatial/build.gradle @@ -12,6 +12,7 @@ esplugin { dependencies { compileOnly project(path: xpackModule('core'), configuration: 'default') testCompile project(path: xpackModule('core'), configuration: 'testArtifacts') + testCompile project(path: ':modules:geo', configuration: 'runtime') } licenseHeaders { diff --git a/x-pack/plugin/spatial/src/test/java/org/elasticsearch/xpack/spatial/index/query/ShapeQueryBuilderTests.java b/x-pack/plugin/spatial/src/test/java/org/elasticsearch/xpack/spatial/index/query/ShapeQueryBuilderTests.java index 48f44a59498..34a4ce76e7a 100644 --- a/x-pack/plugin/spatial/src/test/java/org/elasticsearch/xpack/spatial/index/query/ShapeQueryBuilderTests.java +++ b/x-pack/plugin/spatial/src/test/java/org/elasticsearch/xpack/spatial/index/query/ShapeQueryBuilderTests.java @@ -21,6 +21,7 @@ import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentParser; +import org.elasticsearch.geo.GeoPlugin; import org.elasticsearch.geometry.Geometry; import org.elasticsearch.geometry.ShapeType; import org.elasticsearch.index.get.GetResult; @@ -36,8 +37,8 @@ import org.elasticsearch.xpack.spatial.SpatialPlugin; import org.junit.After; import java.io.IOException; +import java.util.Arrays; import java.util.Collection; -import java.util.Collections; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.instanceOf; @@ -64,7 +65,7 @@ public abstract class ShapeQueryBuilderTests extends AbstractQueryTestCase> getPlugins() { - return Collections.singleton(SpatialPlugin.class); + return Arrays.asList(SpatialPlugin.class, GeoPlugin.class); } protected String fieldName() {