diff --git a/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/MatchOnlyTextFieldMapper.java b/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/MatchOnlyTextFieldMapper.java index cb081ca05ee13..9b6d26abc4292 100644 --- a/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/MatchOnlyTextFieldMapper.java +++ b/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/MatchOnlyTextFieldMapper.java @@ -331,7 +331,7 @@ protected void parseCreateField(ParseContext context) throws IOException { Field field = new Field(fieldType().name(), value, fieldType); context.doc().add(field); - createFieldNamesField(context); + context.addToFieldNames(fieldType().name()); } @Override diff --git a/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/ScaledFloatFieldMapper.java b/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/ScaledFloatFieldMapper.java index 13c6f4d6dc245..7a6d4d2994153 100644 --- a/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/ScaledFloatFieldMapper.java +++ b/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/ScaledFloatFieldMapper.java @@ -365,7 +365,7 @@ protected void parseCreateField(ParseContext context) throws IOException { context.doc().addAll(fields); if (hasDocValues == false && (indexed || stored)) { - createFieldNamesField(context); + context.addToFieldNames(fieldType().name()); } } diff --git a/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/SearchAsYouTypeFieldMapper.java b/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/SearchAsYouTypeFieldMapper.java index a98d4abb43e02..5e86b3d067eb3 100644 --- a/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/SearchAsYouTypeFieldMapper.java +++ b/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/SearchAsYouTypeFieldMapper.java @@ -588,7 +588,7 @@ protected void parseCreateField(ParseContext context) throws IOException { context.doc().add(new Field(prefixField.fieldType().name(), value, prefixField.getLuceneFieldType())); } if (fieldType().fieldType.omitNorms()) { - createFieldNamesField(context); + context.addToFieldNames(fieldType().name()); } } diff --git a/modules/percolator/src/main/java/org/elasticsearch/percolator/PercolatorFieldMapper.java b/modules/percolator/src/main/java/org/elasticsearch/percolator/PercolatorFieldMapper.java index e0568356f3f91..a5174998ff345 100644 --- a/modules/percolator/src/main/java/org/elasticsearch/percolator/PercolatorFieldMapper.java +++ b/modules/percolator/src/main/java/org/elasticsearch/percolator/PercolatorFieldMapper.java @@ -413,7 +413,7 @@ void processQuery(Query query, ParseContext context) { doc.add(new Field(extractionResultField.name(), EXTRACTION_PARTIAL, INDEXED_KEYWORD)); } - createFieldNamesField(context); + context.addToFieldNames(fieldType().name()); doc.add(new NumericDocValuesField(minimumShouldMatchFieldMapper.name(), result.minimumShouldMatch)); } diff --git a/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorFieldMapperTests.java b/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorFieldMapperTests.java index a2a1a3863e108..146ff625c08a8 100644 --- a/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorFieldMapperTests.java +++ b/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorFieldMapperTests.java @@ -287,7 +287,7 @@ public void testExtractTermsAndRanges_partial() throws Exception { ParseContext.Document document = parseContext.doc(); PercolatorFieldMapper.PercolatorFieldType fieldType = (PercolatorFieldMapper.PercolatorFieldType) fieldMapper.fieldType(); - assertThat(document.getFields().size(), equalTo(4)); + assertThat(document.getFields().size(), equalTo(3)); assertThat(document.getFields().get(0).binaryValue().utf8ToString(), equalTo("field\u0000term")); assertThat(document.getField(fieldType.extractionResultField.name()).stringValue(), equalTo(EXTRACTION_PARTIAL)); } diff --git a/plugins/analysis-icu/src/main/java/org/elasticsearch/index/mapper/ICUCollationKeywordFieldMapper.java b/plugins/analysis-icu/src/main/java/org/elasticsearch/index/mapper/ICUCollationKeywordFieldMapper.java index 8199ffc90a38e..e18401cd4d855 100644 --- a/plugins/analysis-icu/src/main/java/org/elasticsearch/index/mapper/ICUCollationKeywordFieldMapper.java +++ b/plugins/analysis-icu/src/main/java/org/elasticsearch/index/mapper/ICUCollationKeywordFieldMapper.java @@ -463,7 +463,7 @@ protected void parseCreateField(ParseContext context) throws IOException { if (hasDocValues) { context.doc().add(new SortedSetDocValuesField(fieldType().name(), binaryValue)); } else if (fieldType.indexOptions() != IndexOptions.NONE || fieldType.stored()) { - createFieldNamesField(context); + context.addToFieldNames(fieldType().name()); } } diff --git a/plugins/mapper-annotated-text/src/main/java/org/elasticsearch/index/mapper/annotatedtext/AnnotatedTextFieldMapper.java b/plugins/mapper-annotated-text/src/main/java/org/elasticsearch/index/mapper/annotatedtext/AnnotatedTextFieldMapper.java index a6fb248584ec8..1adf8412d2ca1 100644 --- a/plugins/mapper-annotated-text/src/main/java/org/elasticsearch/index/mapper/annotatedtext/AnnotatedTextFieldMapper.java +++ b/plugins/mapper-annotated-text/src/main/java/org/elasticsearch/index/mapper/annotatedtext/AnnotatedTextFieldMapper.java @@ -532,7 +532,7 @@ protected void parseCreateField(ParseContext context) throws IOException { Field field = new Field(mappedFieldType.name(), value, fieldType); context.doc().add(field); if (fieldType.omitNorms()) { - createFieldNamesField(context); + context.addToFieldNames(fieldType().name()); } } } diff --git a/server/src/main/java/org/elasticsearch/index/mapper/BinaryFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/BinaryFieldMapper.java index 72dc1576dc8c7..e912b462694bc 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/BinaryFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/BinaryFieldMapper.java @@ -172,7 +172,7 @@ public void indexValue(ParseContext context, byte[] value) { // Only add an entry to the field names field if the field is stored // but has no doc values so exists query will work on a field with // no doc values - createFieldNamesField(context); + context.addToFieldNames(fieldType().name()); } } diff --git a/server/src/main/java/org/elasticsearch/index/mapper/BooleanFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/BooleanFieldMapper.java index 5195830a03551..461f5e7c29edd 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/BooleanFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/BooleanFieldMapper.java @@ -293,7 +293,7 @@ private void indexValue(ParseContext context, Boolean value) { if (hasDocValues) { context.doc().add(new SortedNumericDocValuesField(fieldType().name(), value ? 1 : 0)); } else { - createFieldNamesField(context); + context.addToFieldNames(fieldType().name()); } } diff --git a/server/src/main/java/org/elasticsearch/index/mapper/CompletionFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/CompletionFieldMapper.java index fef30796d08d6..704d2c3b1dd83 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/CompletionFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/CompletionFieldMapper.java @@ -376,7 +376,7 @@ public void parse(ParseContext context) throws IOException { } } - createFieldNamesField(context); + context.addToFieldNames(fieldType().name()); for (CompletionInputMetadata metadata: inputMap.values()) { ParseContext externalValueContext = context.createExternalValueContext(metadata); multiFields.parse(this, externalValueContext); diff --git a/server/src/main/java/org/elasticsearch/index/mapper/DateFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/DateFieldMapper.java index b213f5828aede..d07984ca41213 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/DateFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/DateFieldMapper.java @@ -731,7 +731,7 @@ private void indexValue(ParseContext context, long timestamp) { if (hasDocValues) { context.doc().add(new SortedNumericDocValuesField(fieldType().name(), timestamp)); } else if (store || indexed) { - createFieldNamesField(context); + context.addToFieldNames(fieldType().name()); } if (store) { context.doc().add(new StoredField(fieldType().name(), timestamp)); diff --git a/server/src/main/java/org/elasticsearch/index/mapper/FieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/FieldMapper.java index c22e6949024e8..7fe80c9cebae0 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/FieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/FieldMapper.java @@ -8,7 +8,6 @@ package org.elasticsearch.index.mapper; -import org.apache.lucene.document.Field; import org.apache.lucene.index.LeafReaderContext; import org.elasticsearch.Version; import org.elasticsearch.common.Explicit; @@ -24,7 +23,6 @@ import org.elasticsearch.common.xcontent.support.AbstractXContentParser; import org.elasticsearch.common.xcontent.support.XContentMapValues; import org.elasticsearch.index.analysis.NamedAnalyzer; -import org.elasticsearch.index.mapper.FieldNamesFieldMapper.FieldNamesFieldType; import org.elasticsearch.index.mapper.Mapper.TypeParser.ParserContext; import org.elasticsearch.script.Script; import org.elasticsearch.script.ScriptType; @@ -266,17 +264,6 @@ protected void indexScriptValues(SearchLookup searchLookup, LeafReaderContext re throw new UnsupportedOperationException("FieldMapper " + name() + " does not support [script]"); } - protected final void createFieldNamesField(ParseContext context) { - assert fieldType().hasDocValues() == false : "_field_names should only be used when doc_values are turned off"; - FieldNamesFieldMapper fieldNamesFieldMapper = (FieldNamesFieldMapper) context.getMetadataMapper(FieldNamesFieldMapper.NAME); - if (fieldNamesFieldMapper != null) { - FieldNamesFieldType fieldNamesFieldType = fieldNamesFieldMapper.fieldType(); - if (fieldNamesFieldType != null && fieldNamesFieldType.isEnabled()) { - context.doc().add(new Field(FieldNamesFieldMapper.NAME, fieldType().name(), FieldNamesFieldMapper.Defaults.FIELD_TYPE)); - } - } - } - @Override public Iterator iterator() { Iterator multiFieldsIterator = multiFields.iterator(); diff --git a/server/src/main/java/org/elasticsearch/index/mapper/FieldNamesFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/FieldNamesFieldMapper.java index 57b3443e0e567..4e6431ef7c332 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/FieldNamesFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/FieldNamesFieldMapper.java @@ -8,6 +8,7 @@ package org.elasticsearch.index.mapper; +import org.apache.lucene.document.Field; import org.apache.lucene.document.FieldType; import org.apache.lucene.index.IndexOptions; import org.apache.lucene.search.Query; @@ -17,6 +18,7 @@ import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.index.query.SearchExecutionContext; +import java.io.IOException; import java.util.Collections; import java.util.List; @@ -154,6 +156,22 @@ public FieldNamesFieldType fieldType() { return (FieldNamesFieldType) super.fieldType(); } + @Override + public void postParse(ParseContext context) throws IOException { + if (enabled.value() == false) { + return; + } + for (String field : context.getFieldNames()) { + assert noDocValues(field, context) : "Field " + field + " should not have docvalues"; + context.doc().add(new Field(NAME, field, Defaults.FIELD_TYPE)); + } + } + + private static boolean noDocValues(String field, ParseContext context) { + MappedFieldType ft = context.mappingLookup().getFieldType(field); + return ft == null || ft.hasDocValues() == false; + } + @Override protected String contentType() { return CONTENT_TYPE; diff --git a/server/src/main/java/org/elasticsearch/index/mapper/GeoPointFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/GeoPointFieldMapper.java index e5d8484e8eace..d0f3fce989805 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/GeoPointFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/GeoPointFieldMapper.java @@ -191,7 +191,7 @@ protected void index(ParseContext context, GeoPoint geometry) throws IOException if (fieldType().hasDocValues()) { context.doc().add(new LatLonDocValuesField(fieldType().name(), geometry.lat(), geometry.lon())); } else if (fieldType().isStored() || fieldType().isSearchable()) { - createFieldNamesField(context); + context.addToFieldNames(fieldType().name()); } if (fieldType().isStored()) { context.doc().add(new StoredField(fieldType().name(), geometry.toString())); diff --git a/server/src/main/java/org/elasticsearch/index/mapper/GeoShapeFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/GeoShapeFieldMapper.java index 1811043a07033..faadc06d102a5 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/GeoShapeFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/GeoShapeFieldMapper.java @@ -202,7 +202,7 @@ protected void index(ParseContext context, Geometry geometry) throws IOException return; } context.doc().addAll(indexer.indexShape(geometry)); - createFieldNamesField(context); + context.addToFieldNames(fieldType().name()); } @Override diff --git a/server/src/main/java/org/elasticsearch/index/mapper/IpFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/IpFieldMapper.java index 8b57c0b325ca9..098a1cc77cb90 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/IpFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/IpFieldMapper.java @@ -459,7 +459,7 @@ private void indexValue(ParseContext context, InetAddress address) { if (hasDocValues) { context.doc().add(new SortedSetDocValuesField(fieldType().name(), new BytesRef(InetAddressPoint.encode(address)))); } else if (stored || indexed) { - createFieldNamesField(context); + context.addToFieldNames(fieldType().name()); } if (stored) { context.doc().add(new StoredField(fieldType().name(), new BytesRef(InetAddressPoint.encode(address)))); diff --git a/server/src/main/java/org/elasticsearch/index/mapper/KeywordFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/KeywordFieldMapper.java index e397aa561aaba..26fe154185259 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/KeywordFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/KeywordFieldMapper.java @@ -433,7 +433,7 @@ private void indexValue(ParseContext context, String value) { context.doc().add(field); if (fieldType().hasDocValues() == false && fieldType.omitNorms()) { - createFieldNamesField(context); + context.addToFieldNames(fieldType().name()); } } diff --git a/server/src/main/java/org/elasticsearch/index/mapper/LegacyGeoShapeFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/LegacyGeoShapeFieldMapper.java index 1758220880cb4..0d7bfc68d861d 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/LegacyGeoShapeFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/LegacyGeoShapeFieldMapper.java @@ -496,7 +496,7 @@ protected void index(ParseContext context, ShapeBuilder shapeBuilder) t } } context.doc().addAll(Arrays.asList(fieldType().defaultPrefixTreeStrategy().createIndexableFields(shape))); - createFieldNamesField(context); + context.addToFieldNames(fieldType().name()); } @Override diff --git a/server/src/main/java/org/elasticsearch/index/mapper/NumberFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/NumberFieldMapper.java index b5b426de16661..23fdbe824cfeb 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/NumberFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/NumberFieldMapper.java @@ -1155,7 +1155,7 @@ private void indexValue(ParseContext context, Number numericValue) { indexed, hasDocValues, stored)); if (hasDocValues == false && (stored || indexed)) { - createFieldNamesField(context); + context.addToFieldNames(fieldType().name()); } } diff --git a/server/src/main/java/org/elasticsearch/index/mapper/ParseContext.java b/server/src/main/java/org/elasticsearch/index/mapper/ParseContext.java index 75f280e2a315e..34c78967e2dab 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/ParseContext.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/ParseContext.java @@ -292,6 +292,16 @@ public void addIgnoredField(String field) { public Collection getIgnoredFields() { return in.getIgnoredFields(); } + + @Override + public void addToFieldNames(String field) { + in.addToFieldNames(field); + } + + @Override + public Collection getFieldNames() { + return in.getFieldNames(); + } } public static class InternalParseContext extends ParseContext { @@ -307,6 +317,7 @@ public static class InternalParseContext extends ParseContext { private final Map dynamicObjectMappers = new HashMap<>(); private final List dynamicRuntimeFields = new ArrayList<>(); private final Set ignoredFields = new HashSet<>(); + private final Set fieldNameFields = new HashSet<>(); private Field version; private SeqNoFieldMapper.SequenceIDFields seqID; private long numNestedDocs; @@ -490,6 +501,16 @@ public void addIgnoredField(String field) { public Collection getIgnoredFields() { return Collections.unmodifiableCollection(ignoredFields); } + + @Override + public void addToFieldNames(String field) { + fieldNameFields.add(field); + } + + @Override + public Collection getFieldNames() { + return Collections.unmodifiableCollection(fieldNameFields); + } } /** @@ -509,6 +530,19 @@ public Collection getIgnoredFields() { */ public abstract Collection getIgnoredFields(); + /** + * Add the given {@code field} to the _field_names field + * + * Use this if an exists query run against the field cannot use docvalues + * or norms. + */ + public abstract void addToFieldNames(String field); + + /** + * Return the collection of fields to be added to the _field_names field + */ + public abstract Collection getFieldNames(); + public abstract Mapper.TypeParser.ParserContext parserContext(DateFormatter dateFormatter); /** diff --git a/server/src/main/java/org/elasticsearch/index/mapper/RangeFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/RangeFieldMapper.java index f4a49be19a28b..3e8e475db0c37 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/RangeFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/RangeFieldMapper.java @@ -359,7 +359,7 @@ protected void parseCreateField(ParseContext context) throws IOException { context.doc().addAll(fieldType().rangeType.createFields(context, name(), range, index, hasDocValues, store)); if (hasDocValues == false && (index || store)) { - createFieldNamesField(context); + context.addToFieldNames(fieldType().name()); } } diff --git a/server/src/main/java/org/elasticsearch/index/mapper/RoutingFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/RoutingFieldMapper.java index 6e5f7681ab06d..448a3c4be4344 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/RoutingFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/RoutingFieldMapper.java @@ -104,7 +104,7 @@ public void preParse(ParseContext context) { String routing = context.sourceToParse().routing(); if (routing != null) { context.doc().add(new Field(fieldType().name(), routing, Defaults.FIELD_TYPE)); - createFieldNamesField(context); + context.addToFieldNames(fieldType().name()); } } diff --git a/server/src/main/java/org/elasticsearch/index/mapper/TextFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/TextFieldMapper.java index 1da11ec947438..b8c983ea03cfc 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/TextFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/TextFieldMapper.java @@ -866,7 +866,7 @@ protected void parseCreateField(ParseContext context) throws IOException { Field field = new Field(fieldType().name(), value, fieldType); context.doc().add(field); if (fieldType.omitNorms()) { - createFieldNamesField(context); + context.addToFieldNames(fieldType().name()); } if (prefixFieldInfo != null) { context.doc().add(new Field(prefixFieldInfo.field, value, prefixFieldInfo.fieldType)); diff --git a/server/src/main/java/org/elasticsearch/index/mapper/flattened/FlattenedFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/flattened/FlattenedFieldMapper.java index 25b5665c5da56..a3493e65656de 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/flattened/FlattenedFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/flattened/FlattenedFieldMapper.java @@ -473,7 +473,7 @@ protected void parseCreateField(ParseContext context) throws IOException { context.doc().addAll(fieldParser.parse(xContentParser)); if (mappedFieldType.hasDocValues() == false) { - createFieldNamesField(context); + context.addToFieldNames(fieldType().name()); } } diff --git a/x-pack/plugin/mapper-unsigned-long/src/main/java/org/elasticsearch/xpack/unsignedlong/UnsignedLongFieldMapper.java b/x-pack/plugin/mapper-unsigned-long/src/main/java/org/elasticsearch/xpack/unsignedlong/UnsignedLongFieldMapper.java index 2c39719eac6bc..b4e36facb22b8 100644 --- a/x-pack/plugin/mapper-unsigned-long/src/main/java/org/elasticsearch/xpack/unsignedlong/UnsignedLongFieldMapper.java +++ b/x-pack/plugin/mapper-unsigned-long/src/main/java/org/elasticsearch/xpack/unsignedlong/UnsignedLongFieldMapper.java @@ -488,7 +488,7 @@ protected void parseCreateField(ParseContext context) throws IOException { } context.doc().addAll(fields); if (hasDocValues == false && (stored || indexed)) { - createFieldNamesField(context); + context.addToFieldNames(fieldType().name()); } } diff --git a/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/index/mapper/GeoShapeWithDocValuesFieldMapper.java b/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/index/mapper/GeoShapeWithDocValuesFieldMapper.java index 7811b67ef2e82..71065a458b62c 100644 --- a/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/index/mapper/GeoShapeWithDocValuesFieldMapper.java +++ b/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/index/mapper/GeoShapeWithDocValuesFieldMapper.java @@ -223,7 +223,7 @@ protected void index(ParseContext context, Geometry geometry) throws IOException } docValuesField.add(fields, geometry); } else if (fieldType().isSearchable()) { - createFieldNamesField(context); + context.addToFieldNames(fieldType().name()); } } diff --git a/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/index/mapper/PointFieldMapper.java b/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/index/mapper/PointFieldMapper.java index ad2363979de64..c2850b2ff8e04 100644 --- a/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/index/mapper/PointFieldMapper.java +++ b/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/index/mapper/PointFieldMapper.java @@ -134,7 +134,7 @@ protected void index(ParseContext context, ParsedCartesianPoint point) throws IO if (fieldType().hasDocValues()) { context.doc().add(new XYDocValuesField(fieldType().name(), (float) point.getX(), (float) point.getY())); } else if (fieldType().isStored() || fieldType().isSearchable()) { - createFieldNamesField(context); + context.addToFieldNames(fieldType().name()); } if (fieldType().isStored()) { context.doc().add(new StoredField(fieldType().name(), point.toString())); diff --git a/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/index/mapper/ShapeFieldMapper.java b/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/index/mapper/ShapeFieldMapper.java index cf67d7b9a56ea..3e6b369842d52 100644 --- a/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/index/mapper/ShapeFieldMapper.java +++ b/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/index/mapper/ShapeFieldMapper.java @@ -141,7 +141,7 @@ protected void index(ParseContext context, Geometry geometry) throws IOException return; } context.doc().addAll(indexer.indexShape(geometry)); - createFieldNamesField(context); + context.addToFieldNames(fieldType().name()); } @Override