|
18 | 18 | */
|
19 | 19 | package org.elasticsearch.index.mapper;
|
20 | 20 |
|
21 |
| -import org.apache.lucene.document.Field; |
22 | 21 | import org.apache.lucene.index.IndexOptions;
|
23 | 22 | import org.apache.lucene.index.IndexableField;
|
| 23 | +import org.apache.lucene.index.Term; |
| 24 | +import org.apache.lucene.search.DocValuesFieldExistsQuery; |
24 | 25 | import org.apache.lucene.search.Query;
|
| 26 | +import org.apache.lucene.search.TermQuery; |
25 | 27 | import org.apache.lucene.spatial.prefix.PrefixTreeStrategy;
|
26 | 28 | import org.apache.lucene.spatial.prefix.RecursivePrefixTreeStrategy;
|
27 | 29 | import org.apache.lucene.spatial.prefix.TermQueryPrefixTreeStrategy;
|
28 | 30 | import org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree;
|
29 | 31 | import org.apache.lucene.spatial.prefix.tree.PackedQuadPrefixTree;
|
30 | 32 | import org.apache.lucene.spatial.prefix.tree.QuadPrefixTree;
|
31 | 33 | import org.apache.lucene.spatial.prefix.tree.SpatialPrefixTree;
|
| 34 | +import org.elasticsearch.Version; |
32 | 35 | import org.elasticsearch.common.Explicit;
|
33 | 36 | import org.elasticsearch.common.geo.GeoUtils;
|
34 | 37 | import org.elasticsearch.common.geo.SpatialStrategy;
|
|
44 | 47 | import org.locationtech.spatial4j.shape.jts.JtsGeometry;
|
45 | 48 |
|
46 | 49 | import java.io.IOException;
|
| 50 | +import java.util.ArrayList; |
| 51 | +import java.util.Arrays; |
47 | 52 | import java.util.Iterator;
|
48 | 53 | import java.util.List;
|
49 | 54 | import java.util.Map;
|
@@ -125,6 +130,11 @@ public Builder coerce(boolean coerce) {
|
125 | 130 | return builder;
|
126 | 131 | }
|
127 | 132 |
|
| 133 | + @Override |
| 134 | + protected boolean defaultDocValues(Version indexCreated) { |
| 135 | + return false; |
| 136 | + } |
| 137 | + |
128 | 138 | protected Explicit<Boolean> coerce(BuilderContext context) {
|
129 | 139 | if (coerce != null) {
|
130 | 140 | return new Explicit<>(coerce, true);
|
@@ -406,6 +416,11 @@ public PrefixTreeStrategy resolveStrategy(String strategyName) {
|
406 | 416 | throw new IllegalArgumentException("Unknown prefix tree strategy [" + strategyName + "]");
|
407 | 417 | }
|
408 | 418 |
|
| 419 | + @Override |
| 420 | + public Query existsQuery(QueryShardContext context) { |
| 421 | + return new TermQuery(new Term(FieldNamesFieldMapper.NAME, name())); |
| 422 | + } |
| 423 | + |
409 | 424 | @Override
|
410 | 425 | public Query termQuery(Object value, QueryShardContext context) {
|
411 | 426 | throw new QueryShardException(context, "Geo fields do not support exact searching, use dedicated geo queries instead");
|
@@ -440,11 +455,9 @@ public Mapper parse(ParseContext context) throws IOException {
|
440 | 455 | throw new MapperParsingException("[{" + fieldType().name() + "}] is configured for points only but a " +
|
441 | 456 | ((shape instanceof JtsGeometry) ? ((JtsGeometry)shape).getGeom().getGeometryType() : shape.getClass()) + " was found");
|
442 | 457 | }
|
443 |
| - Field[] fields = fieldType().defaultStrategy().createIndexableFields(shape); |
444 |
| - if (fields == null || fields.length == 0) { |
445 |
| - return null; |
446 |
| - } |
447 |
| - for (Field field : fields) { |
| 458 | + List<IndexableField> fields = new ArrayList<>(Arrays.asList(fieldType().defaultStrategy().createIndexableFields(shape))); |
| 459 | + createFieldNamesField(context, fields); |
| 460 | + for (IndexableField field : fields) { |
448 | 461 | context.doc().add(field);
|
449 | 462 | }
|
450 | 463 | } catch (Exception e) {
|
|
0 commit comments