Skip to content

Commit 5715588

Browse files
committed
fix geo shape to use the new index options
1 parent 53f65d8 commit 5715588

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

src/main/java/org/elasticsearch/index/mapper/geo/GeoShapeFieldMapper.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
import com.spatial4j.core.distance.DistanceUnits;
66
import org.apache.lucene.document.Field;
77
import org.apache.lucene.document.Fieldable;
8+
import org.apache.lucene.index.FieldInfo;
9+
import org.elasticsearch.ElasticSearchIllegalArgumentException;
10+
import org.elasticsearch.common.Strings;
11+
import org.elasticsearch.common.geo.GeoJSONShapeParser;
812
import org.elasticsearch.common.lucene.spatial.SpatialStrategy;
913
import org.elasticsearch.common.lucene.spatial.prefix.TermQueryPrefixTreeStrategy;
1014
import org.elasticsearch.common.lucene.spatial.prefix.tree.GeohashPrefixTree;
1115
import org.elasticsearch.common.lucene.spatial.prefix.tree.QuadPrefixTree;
12-
import org.elasticsearch.ElasticSearchIllegalArgumentException;
13-
import org.elasticsearch.common.Strings;
14-
import org.elasticsearch.common.geo.GeoJSONShapeParser;
1516
import org.elasticsearch.common.lucene.spatial.prefix.tree.SpatialPrefixTree;
1617
import org.elasticsearch.common.xcontent.XContentBuilder;
1718
import org.elasticsearch.index.mapper.FieldMapper;
@@ -25,18 +26,18 @@
2526

2627
/**
2728
* FieldMapper for indexing {@link com.spatial4j.core.shape.Shape}s.
28-
*
29+
* <p/>
2930
* Currently Shapes can only be indexed and can only be queried using
3031
* {@link org.elasticsearch.index.query.GeoShapeFilterParser}, consequently
3132
* a lot of behavior in this Mapper is disabled.
32-
*
33+
* <p/>
3334
* Format supported:
34-
*
35+
* <p/>
3536
* "field" : {
36-
* "type" : "polygon",
37-
* "coordinates" : [
38-
* [ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ]
39-
* ]
37+
* "type" : "polygon",
38+
* "coordinates" : [
39+
* [ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ]
40+
* ]
4041
* }
4142
*/
4243
public class GeoShapeFieldMapper extends AbstractFieldMapper<String> {
@@ -128,7 +129,7 @@ public Mapper.Builder parse(String name, Map<String, Object> node, ParserContext
128129
private final SpatialStrategy spatialStrategy;
129130

130131
public GeoShapeFieldMapper(FieldMapper.Names names, SpatialPrefixTree prefixTree, double distanceErrorPct) {
131-
super(names, Field.Index.NOT_ANALYZED, Field.Store.NO, Field.TermVector.NO, 1, true, true, null, null);
132+
super(names, Field.Index.NOT_ANALYZED, Field.Store.NO, Field.TermVector.NO, 1, true, FieldInfo.IndexOptions.DOCS_ONLY, null, null);
132133
this.spatialStrategy = new TermQueryPrefixTreeStrategy(names, prefixTree, distanceErrorPct);
133134
}
134135

src/main/java/org/elasticsearch/index/mapper/internal/UidFieldMapper.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import org.apache.lucene.document.Field;
2323
import org.apache.lucene.document.Fieldable;
24+
import org.apache.lucene.index.FieldInfo;
2425
import org.apache.lucene.index.Term;
2526
import org.elasticsearch.common.lucene.Lucene;
2627
import org.elasticsearch.common.lucene.uid.UidField;
@@ -48,6 +49,7 @@ public static class Defaults extends AbstractFieldMapper.Defaults {
4849
public static final String NAME = UidFieldMapper.NAME;
4950
public static final Field.Index INDEX = Field.Index.NOT_ANALYZED;
5051
public static final boolean OMIT_NORMS = true;
52+
public static final FieldInfo.IndexOptions INDEX_OPTIONS = FieldInfo.IndexOptions.DOCS_AND_FREQS_AND_POSITIONS; // we store payload (otherwise, we really need just docs)
5153
}
5254

5355
public static class Builder extends Mapper.Builder<Builder, UidFieldMapper> {

0 commit comments

Comments
 (0)