|
@@ -20,6 +20,7 @@ package org.elasticsearch.index.mapper;
|
|
|
|
|
|
import org.apache.lucene.document.FieldType;
|
|
|
import org.apache.lucene.index.IndexableField;
|
|
|
+import org.apache.lucene.search.Query;
|
|
|
import org.apache.lucene.spatial.prefix.PrefixTreeStrategy;
|
|
|
import org.apache.lucene.spatial.prefix.RecursivePrefixTreeStrategy;
|
|
|
import org.apache.lucene.spatial.prefix.TermQueryPrefixTreeStrategy;
|
|
@@ -33,6 +34,7 @@ import org.elasticsearch.common.Explicit;
|
|
|
import org.elasticsearch.common.ParseField;
|
|
|
import org.elasticsearch.common.geo.GeoUtils;
|
|
|
import org.elasticsearch.common.geo.GeometryParser;
|
|
|
+import org.elasticsearch.common.geo.ShapeRelation;
|
|
|
import org.elasticsearch.common.geo.ShapesAvailability;
|
|
|
import org.elasticsearch.common.geo.SpatialStrategy;
|
|
|
import org.elasticsearch.common.geo.builders.ShapeBuilder;
|
|
@@ -47,6 +49,7 @@ import org.elasticsearch.common.xcontent.XContentParser;
|
|
|
import org.elasticsearch.common.xcontent.support.XContentMapValues;
|
|
|
import org.elasticsearch.geometry.Geometry;
|
|
|
import org.elasticsearch.index.query.LegacyGeoShapeQueryProcessor;
|
|
|
+import org.elasticsearch.index.query.QueryShardContext;
|
|
|
import org.locationtech.spatial4j.shape.Shape;
|
|
|
|
|
|
import java.io.IOException;
|
|
@@ -260,7 +263,6 @@ public class LegacyGeoShapeFieldMapper extends AbstractShapeGeometryFieldMapper<
|
|
|
setupPrefixTrees(ft);
|
|
|
ft.setGeometryIndexer(new LegacyGeoShapeIndexer(ft));
|
|
|
ft.setGeometryParser(new LegacyGeoShapeParser());
|
|
|
- ft.setGeometryQueryBuilder(new LegacyGeoShapeQueryProcessor(ft));
|
|
|
ft.setOrientation(orientation == null ? Defaults.ORIENTATION.value() : orientation);
|
|
|
return ft;
|
|
|
}
|
|
@@ -307,7 +309,8 @@ public class LegacyGeoShapeFieldMapper extends AbstractShapeGeometryFieldMapper<
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static final class GeoShapeFieldType extends AbstractShapeGeometryFieldType<ShapeBuilder<?, ?, ?>, Shape> {
|
|
|
+ public static final class GeoShapeFieldType extends AbstractShapeGeometryFieldType<ShapeBuilder<?, ?, ?>, Shape>
|
|
|
+ implements GeoShapeQueryable {
|
|
|
|
|
|
private String tree = DeprecatedParameters.Defaults.TREE;
|
|
|
private SpatialStrategy strategy = DeprecatedParameters.Defaults.STRATEGY;
|
|
@@ -322,14 +325,28 @@ public class LegacyGeoShapeFieldMapper extends AbstractShapeGeometryFieldMapper<
|
|
|
private RecursivePrefixTreeStrategy recursiveStrategy;
|
|
|
private TermQueryPrefixTreeStrategy termStrategy;
|
|
|
|
|
|
+ private final LegacyGeoShapeQueryProcessor queryProcessor;
|
|
|
+
|
|
|
private GeoShapeFieldType(String name, boolean indexed, boolean stored, boolean hasDocValues, Map<String, String> meta) {
|
|
|
super(name, indexed, stored, hasDocValues, meta);
|
|
|
+ this.queryProcessor = new LegacyGeoShapeQueryProcessor(this);
|
|
|
}
|
|
|
|
|
|
public GeoShapeFieldType(String name) {
|
|
|
this(name, true, false, true, Collections.emptyMap());
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Query geoShapeQuery(Geometry shape, String fieldName, ShapeRelation relation, QueryShardContext context) {
|
|
|
+ throw new UnsupportedOperationException("process method should not be called for PrefixTree based geo_shapes");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Query geoShapeQuery(Geometry shape, String fieldName, SpatialStrategy strategy, ShapeRelation relation,
|
|
|
+ QueryShardContext context) {
|
|
|
+ return queryProcessor.geoShapeQuery(shape, fieldName, strategy, relation, context);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public String typeName() {
|
|
|
return CONTENT_TYPE;
|