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 <nknize@gmail.com>
This commit is contained in:
parent
619028c33e
commit
254d1e3543
|
@ -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'
|
||||
}
|
|
@ -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<String, Mapper.TypeParser> getMappers() {
|
||||
return Collections.singletonMap(GeoShapeFieldMapper.CONTENT_TYPE, new AbstractGeometryFieldMapper.TypeParser());
|
||||
}
|
||||
}
|
|
@ -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<Object[]> parameters() throws Exception {
|
||||
return ESClientYamlSuiteTestCase.createParameters();
|
||||
}
|
||||
}
|
|
@ -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.
|
||||
}
|
||||
}
|
|
@ -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}
|
|
@ -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<RankFeat
|
|||
|
||||
@Override
|
||||
protected Collection<Class<? extends Plugin>> getPlugins() {
|
||||
return Collections.singleton(MapperExtrasPlugin.class);
|
||||
return Arrays.asList(MapperExtrasPlugin.class, TestGeoShapeFieldMapperPlugin.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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<ChildrenAggregationBuilder> {
|
||||
|
||||
@Override
|
||||
protected Collection<Class<? extends Plugin>> getPlugins() {
|
||||
return Collections.singleton(ParentJoinPlugin.class);
|
||||
return Arrays.asList(ParentJoinPlugin.class, TestGeoShapeFieldMapperPlugin.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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<ParentAggregationBuilder> {
|
||||
|
||||
@Override
|
||||
protected Collection<Class<? extends Plugin>> getPlugins() {
|
||||
return Collections.singleton(ParentJoinPlugin.class);
|
||||
return Arrays.asList(ParentJoinPlugin.class, TestGeoShapeFieldMapperPlugin.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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<HasChildQue
|
|||
|
||||
@Override
|
||||
protected Collection<Class<? extends Plugin>> getPlugins() {
|
||||
return Collections.singletonList(ParentJoinPlugin.class);
|
||||
return Arrays.asList(ParentJoinPlugin.class, TestGeoShapeFieldMapperPlugin.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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<HasParentQ
|
|||
|
||||
@Override
|
||||
protected Collection<Class<? extends Plugin>> getPlugins() {
|
||||
return Collections.singletonList(ParentJoinPlugin.class);
|
||||
return Arrays.asList(ParentJoinPlugin.class, TestGeoShapeFieldMapperPlugin.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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<ParentIdQue
|
|||
|
||||
@Override
|
||||
protected Collection<Class<? extends Plugin>> getPlugins() {
|
||||
return Collections.singletonList(ParentJoinPlugin.class);
|
||||
return Arrays.asList(ParentJoinPlugin.class, TestGeoShapeFieldMapperPlugin.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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<PercolateQ
|
|||
|
||||
@Override
|
||||
protected Collection<Class<? extends Plugin>> getPlugins() {
|
||||
return Collections.singleton(PercolatorPlugin.class);
|
||||
return Arrays.asList(PercolatorPlugin.class, TestGeoShapeFieldMapperPlugin.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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<Class<? extends Plugin>> 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();
|
||||
|
|
|
@ -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":
|
||||
|
|
|
@ -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<String, Mapper.TypeParser> entry : mapperPlugin.getMappers().entrySet()) {
|
||||
|
|
|
@ -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<Class<? extends Plugin>> getPlugins() {
|
||||
return pluginList(InternalSettingsPlugin.class);
|
||||
return pluginList(InternalSettingsPlugin.class, TestGeoShapeFieldMapperPlugin.class);
|
||||
}
|
||||
|
||||
public void testFieldDisabled() throws Exception {
|
||||
|
|
|
@ -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<Class<? extends Plugin>> getPlugins() {
|
||||
return Collections.singleton(FieldFilterPlugin.class);
|
||||
return Arrays.asList(FieldFilterPlugin.class, TestGeoShapeFieldMapperPlugin.class);
|
||||
}
|
||||
|
||||
@Before
|
||||
|
|
|
@ -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<Class<? extends Plugin>> getPlugins() {
|
||||
return pluginList(InternalSettingsPlugin.class);
|
||||
return pluginList(InternalSettingsPlugin.class, TestGeoShapeFieldMapperPlugin.class);
|
||||
}
|
||||
|
||||
public void testDefaultConfiguration() throws IOException {
|
||||
|
|
|
@ -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<Class<? extends Plugin>> getPlugins() {
|
||||
return pluginList(InternalSettingsPlugin.class);
|
||||
return pluginList(InternalSettingsPlugin.class, TestGeoShapeFieldMapperPlugin.class);
|
||||
}
|
||||
|
||||
public void testDefaultConfiguration() throws IOException {
|
||||
|
|
|
@ -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<TermsSetQue
|
|||
|
||||
@Override
|
||||
protected Collection<Class<? extends Plugin>> getPlugins() {
|
||||
return Collections.singleton(CustomScriptPlugin.class);
|
||||
return Arrays.asList(CustomScriptPlugin.class, TestGeoShapeFieldMapperPlugin.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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<Functi
|
|||
|
||||
@Override
|
||||
protected Collection<Class<? extends Plugin>> getPlugins() {
|
||||
return Collections.singleton(TestPlugin.class);
|
||||
return Arrays.asList(TestPlugin.class, TestGeoShapeFieldMapperPlugin.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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<Class<? extends Plugin>> getPlugins() {
|
||||
return Collections.singleton(TestGeoShapeFieldMapperPlugin.class);
|
||||
}
|
||||
|
||||
protected abstract XContentBuilder createTypedMapping() throws Exception;
|
||||
|
||||
|
|
|
@ -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<Class<? extends Plugin>> getPlugins() {
|
||||
return Collections.emptyList();
|
||||
return Collections.singletonList(TestGeoShapeFieldMapperPlugin.class);
|
||||
}
|
||||
|
||||
protected void initializeAdditionalMappings(MapperService mapperService) throws IOException {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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<String, Mapper.TypeParser> getMappers() {
|
||||
Map<String, Mapper.TypeParser> mappers = new LinkedHashMap<>();
|
||||
mappers.put(GeoShapeFieldMapper.CONTENT_TYPE, new AbstractGeometryFieldMapper.TypeParser());
|
||||
return Collections.unmodifiableMap(mappers);
|
||||
}
|
||||
}
|
|
@ -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')
|
||||
}
|
||||
|
||||
|
|
|
@ -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<Class<? extends Plugin>> 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
|
||||
|
|
|
@ -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<Class<? extends Plugin>> getPlugins() {
|
||||
return Arrays.asList(ReindexPlugin.class, IngestCommonPlugin.class);
|
||||
return Arrays.asList(ReindexPlugin.class, IngestCommonPlugin.class, GeoPlugin.class);
|
||||
}
|
||||
|
||||
private static ThreadPool testThreadPool;
|
||||
|
|
|
@ -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<PinnedQueryBu
|
|||
protected Collection<Class<? extends Plugin>> getPlugins() {
|
||||
List<Class<? extends Plugin>> classpathPlugins = new ArrayList<>();
|
||||
classpathPlugins.add(SearchBusinessRules.class);
|
||||
classpathPlugins.add(TestGeoShapeFieldMapperPlugin.class);
|
||||
return classpathPlugins;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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<Shape
|
|||
|
||||
@Override
|
||||
protected Collection<Class<? extends Plugin>> getPlugins() {
|
||||
return Collections.singleton(SpatialPlugin.class);
|
||||
return Arrays.asList(SpatialPlugin.class, GeoPlugin.class);
|
||||
}
|
||||
|
||||
protected String fieldName() {
|
||||
|
|
Loading…
Reference in New Issue