|
23 | 23 | import org.apache.lucene.document.StoredField;
|
24 | 24 | import org.apache.lucene.index.IndexOptions;
|
25 | 25 | import org.apache.lucene.index.IndexableField;
|
| 26 | +import org.apache.lucene.index.Term; |
| 27 | +import org.apache.lucene.search.DocValuesFieldExistsQuery; |
26 | 28 | import org.apache.lucene.search.Query;
|
| 29 | +import org.apache.lucene.search.TermQuery; |
27 | 30 | import org.elasticsearch.ElasticsearchParseException;
|
28 | 31 | import org.elasticsearch.common.Explicit;
|
29 | 32 | import org.elasticsearch.common.geo.GeoPoint;
|
|
37 | 40 | import org.elasticsearch.index.query.QueryShardException;
|
38 | 41 |
|
39 | 42 | import java.io.IOException;
|
| 43 | +import java.util.ArrayList; |
40 | 44 | import java.util.Iterator;
|
41 | 45 | import java.util.List;
|
42 | 46 | import java.util.Map;
|
@@ -180,6 +184,15 @@ public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
180 | 184 | return new AbstractLatLonPointDVIndexFieldData.Builder();
|
181 | 185 | }
|
182 | 186 |
|
| 187 | + @Override |
| 188 | + public Query existsQuery(QueryShardContext context) { |
| 189 | + if (hasDocValues()) { |
| 190 | + return new DocValuesFieldExistsQuery(name()); |
| 191 | + } else { |
| 192 | + return new TermQuery(new Term(FieldNamesFieldMapper.NAME, name())); |
| 193 | + } |
| 194 | + } |
| 195 | + |
183 | 196 | @Override
|
184 | 197 | public Query termQuery(Object value, QueryShardContext context) {
|
185 | 198 | throw new QueryShardException(context, "Geo fields do not support exact searching, use dedicated geo queries instead: ["
|
@@ -207,6 +220,12 @@ protected void parse(ParseContext context, GeoPoint point) throws IOException {
|
207 | 220 | }
|
208 | 221 | if (fieldType.hasDocValues()) {
|
209 | 222 | context.doc().add(new LatLonDocValuesField(fieldType().name(), point.lat(), point.lon()));
|
| 223 | + } else if (fieldType().stored() || fieldType().indexOptions() != IndexOptions.NONE) { |
| 224 | + List<IndexableField> fields = new ArrayList<>(1); |
| 225 | + createFieldNamesField(context, fields); |
| 226 | + for (IndexableField field : fields) { |
| 227 | + context.doc().add(field); |
| 228 | + } |
210 | 229 | }
|
211 | 230 | // if the mapping contains multifields then use the geohash string
|
212 | 231 | if (multiFields.iterator().hasNext()) {
|
|
0 commit comments