|
@@ -40,7 +40,6 @@ import org.elasticsearch.index.mapper.MappingParserContext;
|
|
|
import org.elasticsearch.index.query.QueryShardException;
|
|
|
import org.elasticsearch.index.query.SearchExecutionContext;
|
|
|
import org.elasticsearch.search.lookup.SearchLookup;
|
|
|
-import org.elasticsearch.xpack.spatial.VectorTileExtension;
|
|
|
import org.elasticsearch.xpack.spatial.index.fielddata.plain.AbstractLatLonShapeIndexFieldData;
|
|
|
import org.elasticsearch.xpack.spatial.search.aggregations.support.GeoShapeValuesSourceType;
|
|
|
|
|
@@ -96,13 +95,13 @@ public class GeoShapeWithDocValuesFieldMapper extends AbstractShapeGeometryField
|
|
|
final Parameter<Map<String, String>> meta = Parameter.metaParam();
|
|
|
|
|
|
private final Version version;
|
|
|
- private final VectorTileExtension vectorTileExtension;
|
|
|
+ private final GeoFormatterFactory<Geometry> geoFormatterFactory;
|
|
|
|
|
|
public Builder(String name, Version version, boolean ignoreMalformedByDefault, boolean coerceByDefault,
|
|
|
- VectorTileExtension vectorTileExtension) {
|
|
|
+ GeoFormatterFactory<Geometry> geoFormatterFactory) {
|
|
|
super(name);
|
|
|
this.version = version;
|
|
|
- this.vectorTileExtension = vectorTileExtension;
|
|
|
+ this.geoFormatterFactory = geoFormatterFactory;
|
|
|
this.ignoreMalformed = ignoreMalformedParam(m -> builder(m).ignoreMalformed.get(), ignoreMalformedByDefault);
|
|
|
this.coerce = coerceParam(m -> builder(m).coerce.get(), coerceByDefault);
|
|
|
this.hasDocValues
|
|
@@ -134,7 +133,7 @@ public class GeoShapeWithDocValuesFieldMapper extends AbstractShapeGeometryField
|
|
|
hasDocValues.get(),
|
|
|
orientation.get().value(),
|
|
|
parser,
|
|
|
- vectorTileExtension,
|
|
|
+ geoFormatterFactory,
|
|
|
meta.get());
|
|
|
return new GeoShapeWithDocValuesFieldMapper(name, ft,
|
|
|
multiFieldsBuilder.build(this, contentPath), copyTo.build(),
|
|
@@ -145,12 +144,12 @@ public class GeoShapeWithDocValuesFieldMapper extends AbstractShapeGeometryField
|
|
|
|
|
|
public static final class GeoShapeWithDocValuesFieldType extends AbstractShapeGeometryFieldType<Geometry> implements GeoShapeQueryable {
|
|
|
|
|
|
- private final VectorTileExtension vectorTileExtension;
|
|
|
+ private final GeoFormatterFactory<Geometry> geoFormatterFactory;
|
|
|
public GeoShapeWithDocValuesFieldType(String name, boolean indexed, boolean hasDocValues,
|
|
|
Orientation orientation, GeoShapeParser parser,
|
|
|
- VectorTileExtension vectorTileExtension, Map<String, String> meta) {
|
|
|
+ GeoFormatterFactory<Geometry> geoFormatterFactory, Map<String, String> meta) {
|
|
|
super(name, indexed, false, hasDocValues, parser, orientation, meta);
|
|
|
- this.vectorTileExtension = vectorTileExtension;
|
|
|
+ this.geoFormatterFactory = geoFormatterFactory;
|
|
|
}
|
|
|
|
|
|
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName, Supplier<SearchLookup> searchLookup) {
|
|
@@ -184,22 +183,16 @@ public class GeoShapeWithDocValuesFieldMapper extends AbstractShapeGeometryField
|
|
|
|
|
|
@Override
|
|
|
protected Function<List<Geometry>, List<Object>> getFormatter(String format) {
|
|
|
- return GeoFormatterFactory.getFormatter(format, Function.identity(),
|
|
|
- (z, x, y, extent) -> {
|
|
|
- if (vectorTileExtension == null) {
|
|
|
- throw new IllegalArgumentException("vector tile format is not supported");
|
|
|
- }
|
|
|
- return vectorTileExtension.getVectorTileEngine().getFormatter(z, x, y, extent);
|
|
|
- });
|
|
|
+ return geoFormatterFactory.getFormatter(format, Function.identity());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public static class TypeParser implements Mapper.TypeParser {
|
|
|
|
|
|
- private final VectorTileExtension vectorTileExtension;
|
|
|
+ private final GeoFormatterFactory<Geometry> geoFormatterFactory;
|
|
|
|
|
|
- public TypeParser(VectorTileExtension vectorTileExtension) {
|
|
|
- this.vectorTileExtension = vectorTileExtension;
|
|
|
+ public TypeParser(GeoFormatterFactory<Geometry> geoFormatterFactory) {
|
|
|
+ this.geoFormatterFactory = geoFormatterFactory;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -226,7 +219,7 @@ public class GeoShapeWithDocValuesFieldMapper extends AbstractShapeGeometryField
|
|
|
parserContext.indexVersionCreated(),
|
|
|
ignoreMalformedByDefault,
|
|
|
coerceByDefault,
|
|
|
- vectorTileExtension);
|
|
|
+ geoFormatterFactory);
|
|
|
}
|
|
|
builder.parse(name, parserContext, node);
|
|
|
return builder;
|
|
@@ -281,7 +274,7 @@ public class GeoShapeWithDocValuesFieldMapper extends AbstractShapeGeometryField
|
|
|
builder.version,
|
|
|
builder.ignoreMalformed.getDefaultValue().value(),
|
|
|
builder.coerce.getDefaultValue().value(),
|
|
|
- builder.vectorTileExtension
|
|
|
+ builder.geoFormatterFactory
|
|
|
).init(this);
|
|
|
}
|
|
|
|