mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-20 03:45:02 +00:00
fix geo shape to use the new index options
This commit is contained in:
parent
53f65d8ff2
commit
5715588b96
@ -5,13 +5,14 @@ import com.spatial4j.core.context.jts.JtsSpatialContext;
|
|||||||
import com.spatial4j.core.distance.DistanceUnits;
|
import com.spatial4j.core.distance.DistanceUnits;
|
||||||
import org.apache.lucene.document.Field;
|
import org.apache.lucene.document.Field;
|
||||||
import org.apache.lucene.document.Fieldable;
|
import org.apache.lucene.document.Fieldable;
|
||||||
|
import org.apache.lucene.index.FieldInfo;
|
||||||
|
import org.elasticsearch.ElasticSearchIllegalArgumentException;
|
||||||
|
import org.elasticsearch.common.Strings;
|
||||||
|
import org.elasticsearch.common.geo.GeoJSONShapeParser;
|
||||||
import org.elasticsearch.common.lucene.spatial.SpatialStrategy;
|
import org.elasticsearch.common.lucene.spatial.SpatialStrategy;
|
||||||
import org.elasticsearch.common.lucene.spatial.prefix.TermQueryPrefixTreeStrategy;
|
import org.elasticsearch.common.lucene.spatial.prefix.TermQueryPrefixTreeStrategy;
|
||||||
import org.elasticsearch.common.lucene.spatial.prefix.tree.GeohashPrefixTree;
|
import org.elasticsearch.common.lucene.spatial.prefix.tree.GeohashPrefixTree;
|
||||||
import org.elasticsearch.common.lucene.spatial.prefix.tree.QuadPrefixTree;
|
import org.elasticsearch.common.lucene.spatial.prefix.tree.QuadPrefixTree;
|
||||||
import org.elasticsearch.ElasticSearchIllegalArgumentException;
|
|
||||||
import org.elasticsearch.common.Strings;
|
|
||||||
import org.elasticsearch.common.geo.GeoJSONShapeParser;
|
|
||||||
import org.elasticsearch.common.lucene.spatial.prefix.tree.SpatialPrefixTree;
|
import org.elasticsearch.common.lucene.spatial.prefix.tree.SpatialPrefixTree;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.index.mapper.FieldMapper;
|
import org.elasticsearch.index.mapper.FieldMapper;
|
||||||
@ -25,18 +26,18 @@ import java.util.Map;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* FieldMapper for indexing {@link com.spatial4j.core.shape.Shape}s.
|
* FieldMapper for indexing {@link com.spatial4j.core.shape.Shape}s.
|
||||||
*
|
* <p/>
|
||||||
* Currently Shapes can only be indexed and can only be queried using
|
* Currently Shapes can only be indexed and can only be queried using
|
||||||
* {@link org.elasticsearch.index.query.GeoShapeFilterParser}, consequently
|
* {@link org.elasticsearch.index.query.GeoShapeFilterParser}, consequently
|
||||||
* a lot of behavior in this Mapper is disabled.
|
* a lot of behavior in this Mapper is disabled.
|
||||||
*
|
* <p/>
|
||||||
* Format supported:
|
* Format supported:
|
||||||
*
|
* <p/>
|
||||||
* "field" : {
|
* "field" : {
|
||||||
* "type" : "polygon",
|
* "type" : "polygon",
|
||||||
* "coordinates" : [
|
* "coordinates" : [
|
||||||
* [ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ]
|
* [ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ]
|
||||||
* ]
|
* ]
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
public class GeoShapeFieldMapper extends AbstractFieldMapper<String> {
|
public class GeoShapeFieldMapper extends AbstractFieldMapper<String> {
|
||||||
@ -128,7 +129,7 @@ public class GeoShapeFieldMapper extends AbstractFieldMapper<String> {
|
|||||||
private final SpatialStrategy spatialStrategy;
|
private final SpatialStrategy spatialStrategy;
|
||||||
|
|
||||||
public GeoShapeFieldMapper(FieldMapper.Names names, SpatialPrefixTree prefixTree, double distanceErrorPct) {
|
public GeoShapeFieldMapper(FieldMapper.Names names, SpatialPrefixTree prefixTree, double distanceErrorPct) {
|
||||||
super(names, Field.Index.NOT_ANALYZED, Field.Store.NO, Field.TermVector.NO, 1, true, true, null, null);
|
super(names, Field.Index.NOT_ANALYZED, Field.Store.NO, Field.TermVector.NO, 1, true, FieldInfo.IndexOptions.DOCS_ONLY, null, null);
|
||||||
this.spatialStrategy = new TermQueryPrefixTreeStrategy(names, prefixTree, distanceErrorPct);
|
this.spatialStrategy = new TermQueryPrefixTreeStrategy(names, prefixTree, distanceErrorPct);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ package org.elasticsearch.index.mapper.internal;
|
|||||||
|
|
||||||
import org.apache.lucene.document.Field;
|
import org.apache.lucene.document.Field;
|
||||||
import org.apache.lucene.document.Fieldable;
|
import org.apache.lucene.document.Fieldable;
|
||||||
|
import org.apache.lucene.index.FieldInfo;
|
||||||
import org.apache.lucene.index.Term;
|
import org.apache.lucene.index.Term;
|
||||||
import org.elasticsearch.common.lucene.Lucene;
|
import org.elasticsearch.common.lucene.Lucene;
|
||||||
import org.elasticsearch.common.lucene.uid.UidField;
|
import org.elasticsearch.common.lucene.uid.UidField;
|
||||||
@ -48,6 +49,7 @@ public class UidFieldMapper extends AbstractFieldMapper<Uid> implements Internal
|
|||||||
public static final String NAME = UidFieldMapper.NAME;
|
public static final String NAME = UidFieldMapper.NAME;
|
||||||
public static final Field.Index INDEX = Field.Index.NOT_ANALYZED;
|
public static final Field.Index INDEX = Field.Index.NOT_ANALYZED;
|
||||||
public static final boolean OMIT_NORMS = true;
|
public static final boolean OMIT_NORMS = true;
|
||||||
|
public static final FieldInfo.IndexOptions INDEX_OPTIONS = FieldInfo.IndexOptions.DOCS_AND_FREQS_AND_POSITIONS; // we store payload (otherwise, we really need just docs)
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder extends Mapper.Builder<Builder, UidFieldMapper> {
|
public static class Builder extends Mapper.Builder<Builder, UidFieldMapper> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user