From 5203205808d1aa74f7730ab4f770f68343fcc020 Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Tue, 19 May 2015 17:48:02 -0700 Subject: [PATCH] Mappings: Cleanup names handling This clarifies some of the uses of names, so that the ambiguous "name" is mostly no longer used (does this include path or not?). sourcePath is also removed as it was not used. Not all the uses of .name() have been cleaned up because Mapper still has this, and ObjectMapper depends on it returning the short name, but I would like to leave finishing that cleanup for a future issue. --- .../TransportGetFieldMappingsIndexAction.java | 4 +- .../plain/DisabledIndexFieldData.java | 2 +- .../plain/DocValuesIndexFieldData.java | 2 +- .../index/mapper/ContentPath.java | 18 +---- .../index/mapper/FieldMapper.java | 68 ++++++------------- .../mapper/core/AbstractFieldMapper.java | 31 +++++---- .../mapper/core/CompletionFieldMapper.java | 2 +- .../mapper/core/TokenCountFieldMapper.java | 2 +- .../index/mapper/geo/GeoPointFieldMapper.java | 2 +- .../index/mapper/internal/AllFieldMapper.java | 2 +- .../mapper/internal/TypeFieldMapper.java | 2 +- .../index/mapper/internal/UidFieldMapper.java | 6 +- .../elasticsearch/index/shard/IndexShard.java | 2 +- .../elasticsearch/search/SearchService.java | 8 +-- .../search/highlight/HighlightUtils.java | 2 +- .../SourceScoreOrderFragmentsBuilder.java | 2 +- .../SourceSimpleFragmentsBuilder.java | 2 +- .../mapper/externalvalues/ExternalMapper.java | 2 +- .../CompletionPostingsFormatTest.java | 2 +- 19 files changed, 57 insertions(+), 104 deletions(-) diff --git a/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/TransportGetFieldMappingsIndexAction.java b/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/TransportGetFieldMappingsIndexAction.java index ab6b31c0bb6..305d8015edf 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/TransportGetFieldMappingsIndexAction.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/TransportGetFieldMappingsIndexAction.java @@ -201,8 +201,8 @@ public class TransportGetFieldMappingsIndexAction extends TransportSingleCustomO } for (Iterator> it = remainingFieldMappers.iterator(); it.hasNext(); ) { final FieldMapper fieldMapper = it.next(); - if (Regex.simpleMatch(field, fieldMapper.names().name())) { - addFieldMapper(fieldMapper.names().name(), fieldMapper, fieldMappings, request.includeDefaults()); + if (Regex.simpleMatch(field, fieldMapper.names().shortName())) { + addFieldMapper(fieldMapper.names().shortName(), fieldMapper, fieldMappings, request.includeDefaults()); it.remove(); } } diff --git a/src/main/java/org/elasticsearch/index/fielddata/plain/DisabledIndexFieldData.java b/src/main/java/org/elasticsearch/index/fielddata/plain/DisabledIndexFieldData.java index 425f85e81fa..30d43ecc8fa 100644 --- a/src/main/java/org/elasticsearch/index/fielddata/plain/DisabledIndexFieldData.java +++ b/src/main/java/org/elasticsearch/index/fielddata/plain/DisabledIndexFieldData.java @@ -61,7 +61,7 @@ public final class DisabledIndexFieldData extends AbstractIndexFieldData filter = fdSettings.getGroups("filter"); if (filter != null && !filter.isEmpty()) { - throw new IllegalArgumentException("Doc values field data doesn't support filters [" + fieldNames.name() + "]"); + throw new IllegalArgumentException("Doc values field data doesn't support filters [" + fieldNames.fullName() + "]"); } if (BINARY_INDEX_FIELD_NAMES.contains(fieldNames.indexName())) { diff --git a/src/main/java/org/elasticsearch/index/mapper/ContentPath.java b/src/main/java/org/elasticsearch/index/mapper/ContentPath.java index 0d58b3fbff9..47c43720162 100644 --- a/src/main/java/org/elasticsearch/index/mapper/ContentPath.java +++ b/src/main/java/org/elasticsearch/index/mapper/ContentPath.java @@ -19,12 +19,9 @@ package org.elasticsearch.index.mapper; -/** - * - */ public class ContentPath { - public static enum Type { + public enum Type { JUST_NAME, FULL, } @@ -41,8 +38,6 @@ public class ContentPath { private String[] path = new String[10]; - private String sourcePath; - public ContentPath() { this(0); } @@ -60,7 +55,6 @@ public class ContentPath { public void reset() { this.index = 0; - this.sourcePath = null; } public void add(String name) { @@ -99,14 +93,4 @@ public class ContentPath { public void pathType(Type type) { this.pathType = type; } - - public String sourcePath(String sourcePath) { - String orig = this.sourcePath; - this.sourcePath = sourcePath; - return orig; - } - - public String sourcePath() { - return this.sourcePath; - } } diff --git a/src/main/java/org/elasticsearch/index/mapper/FieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/FieldMapper.java index 67c14842032..29a74e1c973 100644 --- a/src/main/java/org/elasticsearch/index/mapper/FieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/FieldMapper.java @@ -44,41 +44,34 @@ import java.util.List; */ public interface FieldMapper extends Mapper { - public static final String DOC_VALUES_FORMAT = "doc_values_format"; + String DOC_VALUES_FORMAT = "doc_values_format"; - public static class Names { + class Names { - private final String name; + private final String shortName; private final String indexName; - private final String indexNameClean; + private final String originalIndexName; private final String fullName; - private final String sourcePath; - public Names(String name) { this(name, name, name, name); } - public Names(String name, String indexName, String indexNameClean, String fullName) { - this(name, indexName, indexNameClean, fullName, fullName); - } - - public Names(String name, String indexName, String indexNameClean, String fullName, @Nullable String sourcePath) { - this.name = name; + public Names(String shortName, String indexName, String originalIndexName, String fullName) { + this.shortName = shortName; this.indexName = indexName; - this.indexNameClean = indexNameClean; + this.originalIndexName = originalIndexName; this.fullName = fullName; - this.sourcePath = sourcePath == null ? this.fullName : sourcePath; } /** * The logical name of the field. */ - public String name() { - return name; + public String shortName() { + return shortName; } /** @@ -90,10 +83,10 @@ public interface FieldMapper extends Mapper { } /** - * The cleaned index name, before any "path" modifications performed on it. + * The original index name, before any "path" modifications performed on it. */ - public String indexNameClean() { - return indexNameClean; + public String originalIndexName() { + return originalIndexName; } /** @@ -103,27 +96,6 @@ public interface FieldMapper extends Mapper { return fullName; } - /** - * The dot path notation to extract the value from source. - */ - public String sourcePath() { - return sourcePath; - } - - /** - * Creates a new index term based on the provided value. - */ - public Term createIndexNameTerm(String value) { - return new Term(indexName, value); - } - - /** - * Creates a new index term based on the provided value. - */ - public Term createIndexNameTerm(BytesRef value) { - return new Term(indexName, value); - } - @Override public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) return false; @@ -132,25 +104,23 @@ public interface FieldMapper extends Mapper { if (!fullName.equals(names.fullName)) return false; if (!indexName.equals(names.indexName)) return false; - if (!indexNameClean.equals(names.indexNameClean)) return false; - if (!name.equals(names.name)) return false; - if (!sourcePath.equals(names.sourcePath)) return false; + if (!originalIndexName.equals(names.originalIndexName)) return false; + if (!shortName.equals(names.shortName)) return false; return true; } @Override public int hashCode() { - int result = name.hashCode(); + int result = shortName.hashCode(); result = 31 * result + indexName.hashCode(); - result = 31 * result + indexNameClean.hashCode(); + result = 31 * result + originalIndexName.hashCode(); result = 31 * result + fullName.hashCode(); - result = 31 * result + sourcePath.hashCode(); return result; } } - public static enum Loading { + enum Loading { LAZY { @Override public String toString() { @@ -220,7 +190,7 @@ public interface FieldMapper extends Mapper { /** * List of fields where this field should be copied to */ - public AbstractFieldMapper.CopyTo copyTo(); + AbstractFieldMapper.CopyTo copyTo(); /** * Returns the actual value of the field. @@ -285,7 +255,7 @@ public interface FieldMapper extends Mapper { * * @return If the field is available before indexing or not. * */ - public boolean isGenerated(); + boolean isGenerated(); /** * Parse using the provided {@link ParseContext} and return a mapping diff --git a/src/main/java/org/elasticsearch/index/mapper/core/AbstractFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/core/AbstractFieldMapper.java index 58ed993d9e4..c387043f91a 100644 --- a/src/main/java/org/elasticsearch/index/mapper/core/AbstractFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/core/AbstractFieldMapper.java @@ -19,7 +19,6 @@ package org.elasticsearch.index.mapper.core; -import com.carrotsearch.hppc.ObjectHashSet; import com.carrotsearch.hppc.cursors.ObjectCursor; import com.carrotsearch.hppc.cursors.ObjectObjectCursor; import com.google.common.base.Function; @@ -33,7 +32,6 @@ import org.apache.lucene.index.IndexOptions; import org.apache.lucene.index.Term; import org.apache.lucene.index.Terms; import org.apache.lucene.queries.TermsQuery; -import org.apache.lucene.search.Filter; import org.apache.lucene.search.FuzzyQuery; import org.apache.lucene.search.MultiTermQuery; import org.apache.lucene.search.PrefixQuery; @@ -261,7 +259,7 @@ public abstract class AbstractFieldMapper implements FieldMapper { } protected Names buildNames(BuilderContext context) { - return new Names(name, buildIndexName(context), buildIndexNameClean(context), buildFullName(context), context.path().sourcePath()); + return new Names(name, buildIndexName(context), buildIndexNameClean(context), buildFullName(context)); } protected String buildIndexName(BuilderContext context) { @@ -364,7 +362,8 @@ public abstract class AbstractFieldMapper implements FieldMapper { @Override public String name() { - return names.name(); + // TODO: cleanup names so Mapper knows about paths, so that it is always clear whether we are using short or full name + return names.shortName(); } @Override @@ -475,7 +474,7 @@ public abstract class AbstractFieldMapper implements FieldMapper { @Override public Query termQuery(Object value, @Nullable QueryParseContext context) { - return new TermQuery(names().createIndexNameTerm(indexedValueForSearch(value))); + return new TermQuery(createTerm(value)); } @Override @@ -509,12 +508,12 @@ public abstract class AbstractFieldMapper implements FieldMapper { @Override public Query fuzzyQuery(String value, Fuzziness fuzziness, int prefixLength, int maxExpansions, boolean transpositions) { - return new FuzzyQuery(names.createIndexNameTerm(indexedValueForSearch(value)), fuzziness.asDistance(value), prefixLength, maxExpansions, transpositions); + return new FuzzyQuery(createTerm(value), fuzziness.asDistance(value), prefixLength, maxExpansions, transpositions); } @Override public Query prefixQuery(Object value, @Nullable MultiTermQuery.RewriteMethod method, @Nullable QueryParseContext context) { - PrefixQuery query = new PrefixQuery(names().createIndexNameTerm(indexedValueForSearch(value))); + PrefixQuery query = new PrefixQuery(createTerm(value)); if (method != null) { query.setRewriteMethod(method); } @@ -523,13 +522,17 @@ public abstract class AbstractFieldMapper implements FieldMapper { @Override public Query regexpQuery(Object value, int flags, int maxDeterminizedStates, @Nullable MultiTermQuery.RewriteMethod method, @Nullable QueryParseContext context) { - RegexpQuery query = new RegexpQuery(names().createIndexNameTerm(indexedValueForSearch(value)), flags, maxDeterminizedStates); + RegexpQuery query = new RegexpQuery(createTerm(value), flags, maxDeterminizedStates); if (method != null) { query.setRewriteMethod(method); } return query; } + protected Term createTerm(Object value) { + return new Term(names.indexName(), indexedValueForSearch(value)); + } + @Override public Query nullValueFilter() { return null; @@ -629,7 +632,7 @@ public abstract class AbstractFieldMapper implements FieldMapper { @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { - builder.startObject(names.name()); + builder.startObject(names.shortName()); boolean includeDefaults = params.paramAsBoolean("include_defaults", false); doXContentBody(builder, includeDefaults, params); return builder.endObject(); @@ -638,8 +641,8 @@ public abstract class AbstractFieldMapper implements FieldMapper { protected void doXContentBody(XContentBuilder builder, boolean includeDefaults, Params params) throws IOException { builder.field("type", contentType()); - if (indexCreatedBefore2x && (includeDefaults || !names.name().equals(names.indexNameClean()))) { - builder.field("index_name", names.indexNameClean()); + if (indexCreatedBefore2x && (includeDefaults || !names.shortName().equals(names.originalIndexName()))) { + builder.field("index_name", names.originalIndexName()); } if (includeDefaults || boost != 1.0f) { @@ -864,7 +867,7 @@ public abstract class AbstractFieldMapper implements FieldMapper { ContentPath.Type origPathType = context.path().pathType(); context.path().pathType(pathType); - context.path().add(mainField.name()); + context.path().add(mainField.names().shortName()); for (ObjectCursor cursor : mappers.values()) { cursor.value.parse(context); } @@ -881,7 +884,7 @@ public abstract class AbstractFieldMapper implements FieldMapper { for (ObjectCursor cursor : mergeWithMultiField.multiFields.mappers.values()) { FieldMapper mergeWithMapper = cursor.value; - Mapper mergeIntoMapper = mappers.get(mergeWithMapper.name()); + Mapper mergeIntoMapper = mappers.get(mergeWithMapper.names().shortName()); if (mergeIntoMapper == null) { // no mapping, simply add it if not simulating if (!mergeResult.simulate()) { @@ -892,7 +895,7 @@ public abstract class AbstractFieldMapper implements FieldMapper { if (newMappersBuilder == null) { newMappersBuilder = ImmutableOpenMap.builder(mappers); } - newMappersBuilder.put(mergeWithMapper.name(), mergeWithMapper); + newMappersBuilder.put(mergeWithMapper.names().shortName(), mergeWithMapper); if (mergeWithMapper instanceof AbstractFieldMapper) { if (newFieldMappers == null) { newFieldMappers = new ArrayList<>(2); diff --git a/src/main/java/org/elasticsearch/index/mapper/core/CompletionFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/core/CompletionFieldMapper.java index 738ea401e7d..c10908cec04 100644 --- a/src/main/java/org/elasticsearch/index/mapper/core/CompletionFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/core/CompletionFieldMapper.java @@ -461,7 +461,7 @@ public class CompletionFieldMapper extends AbstractFieldMapper { @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { - builder.startObject(name()) + builder.startObject(names().shortName()) .field(Fields.TYPE, CONTENT_TYPE); builder.field(Fields.ANALYZER, indexAnalyzer.name()); diff --git a/src/main/java/org/elasticsearch/index/mapper/core/TokenCountFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/core/TokenCountFieldMapper.java index 1d4a727d5cf..c13268b1988 100644 --- a/src/main/java/org/elasticsearch/index/mapper/core/TokenCountFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/core/TokenCountFieldMapper.java @@ -144,7 +144,7 @@ public class TokenCountFieldMapper extends IntegerFieldMapper { if (valueAndBoost.value() == null) { count = nullValue(); } else { - count = countPositions(analyzer.analyzer().tokenStream(name(), valueAndBoost.value())); + count = countPositions(analyzer.analyzer().tokenStream(names().shortName(), valueAndBoost.value())); } addIntegerFields(context, fields, count, valueAndBoost.boost()); } diff --git a/src/main/java/org/elasticsearch/index/mapper/geo/GeoPointFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/geo/GeoPointFieldMapper.java index ccc5d4d6d8a..f556678d371 100644 --- a/src/main/java/org/elasticsearch/index/mapper/geo/GeoPointFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/geo/GeoPointFieldMapper.java @@ -515,7 +515,7 @@ public class GeoPointFieldMapper extends AbstractFieldMapper implement public Mapper parse(ParseContext context) throws IOException { ContentPath.Type origPathType = context.path().pathType(); context.path().pathType(pathType); - context.path().add(name()); + context.path().add(names().shortName()); GeoPoint sparse = context.parseExternalValue(GeoPoint.class); diff --git a/src/main/java/org/elasticsearch/index/mapper/internal/AllFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/internal/AllFieldMapper.java index 9b8e33204c5..f574b4877a4 100644 --- a/src/main/java/org/elasticsearch/index/mapper/internal/AllFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/internal/AllFieldMapper.java @@ -193,7 +193,7 @@ public class AllFieldMapper extends AbstractFieldMapper implements RootM @Override public Query termQuery(Object value, QueryParseContext context) { - return queryStringTermQuery(names().createIndexNameTerm(indexedValueForSearch(value))); + return queryStringTermQuery(createTerm(value)); } @Override diff --git a/src/main/java/org/elasticsearch/index/mapper/internal/TypeFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/internal/TypeFieldMapper.java index 117690ed481..1a5e2c40903 100644 --- a/src/main/java/org/elasticsearch/index/mapper/internal/TypeFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/internal/TypeFieldMapper.java @@ -133,7 +133,7 @@ public class TypeFieldMapper extends AbstractFieldMapper implements Root if (fieldType.indexOptions() == IndexOptions.NONE) { return new ConstantScoreQuery(new PrefixQuery(new Term(UidFieldMapper.NAME, Uid.typePrefixAsBytes(BytesRefs.toBytesRef(value))))); } - return new ConstantScoreQuery(new TermQuery(names().createIndexNameTerm(BytesRefs.toBytesRef(value)))); + return new ConstantScoreQuery(new TermQuery(createTerm(value))); } @Override diff --git a/src/main/java/org/elasticsearch/index/mapper/internal/UidFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/internal/UidFieldMapper.java index f71afd60cd7..0beb35f389b 100644 --- a/src/main/java/org/elasticsearch/index/mapper/internal/UidFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/internal/UidFieldMapper.java @@ -184,12 +184,8 @@ public class UidFieldMapper extends AbstractFieldMapper implements RootMapp return Uid.createUid(value.toString()); } - public Term term(String type, String id) { - return term(Uid.createUid(type, id)); - } - public Term term(String uid) { - return names().createIndexNameTerm(uid); + return createTerm(uid); } @Override diff --git a/src/main/java/org/elasticsearch/index/shard/IndexShard.java b/src/main/java/org/elasticsearch/index/shard/IndexShard.java index c5a4209ab84..e2ebf5579ba 100644 --- a/src/main/java/org/elasticsearch/index/shard/IndexShard.java +++ b/src/main/java/org/elasticsearch/index/shard/IndexShard.java @@ -534,7 +534,7 @@ public class IndexShard extends AbstractIndexShardComponent { public Engine.Delete prepareDelete(String type, String id, long version, VersionType versionType, Engine.Operation.Origin origin) { long startTime = System.nanoTime(); final DocumentMapper documentMapper = docMapper(type).v1(); - return new Engine.Delete(type, id, documentMapper.uidMapper().term(type, id), version, versionType, origin, startTime, false); + return new Engine.Delete(type, id, documentMapper.uidMapper().term(Uid.createUid(type, id)), version, versionType, origin, startTime, false); } public void delete(Engine.Delete delete) { diff --git a/src/main/java/org/elasticsearch/search/SearchService.java b/src/main/java/org/elasticsearch/search/SearchService.java index e3eacef0160..09e3f2d9a5b 100644 --- a/src/main/java/org/elasticsearch/search/SearchService.java +++ b/src/main/java/org/elasticsearch/search/SearchService.java @@ -924,10 +924,10 @@ public class SearchService extends AbstractLifecycleComponent { final long start = System.nanoTime(); indexFieldDataService.getForField(fieldMapper).load(ctx); if (indexShard.warmerService().logger().isTraceEnabled()) { - indexShard.warmerService().logger().trace("warmed fielddata for [{}], took [{}]", fieldMapper.names().name(), TimeValue.timeValueNanos(System.nanoTime() - start)); + indexShard.warmerService().logger().trace("warmed fielddata for [{}], took [{}]", fieldMapper.names().fullName(), TimeValue.timeValueNanos(System.nanoTime() - start)); } } catch (Throwable t) { - indexShard.warmerService().logger().warn("failed to warm-up fielddata for [{}]", t, fieldMapper.names().name()); + indexShard.warmerService().logger().warn("failed to warm-up fielddata for [{}]", t, fieldMapper.names().fullName()); } finally { latch.countDown(); } @@ -976,10 +976,10 @@ public class SearchService extends AbstractLifecycleComponent { IndexFieldData.Global ifd = indexFieldDataService.getForField(fieldMapper); ifd.loadGlobal(context.reader()); if (indexShard.warmerService().logger().isTraceEnabled()) { - indexShard.warmerService().logger().trace("warmed global ordinals for [{}], took [{}]", fieldMapper.names().name(), TimeValue.timeValueNanos(System.nanoTime() - start)); + indexShard.warmerService().logger().trace("warmed global ordinals for [{}], took [{}]", fieldMapper.names().fullName(), TimeValue.timeValueNanos(System.nanoTime() - start)); } } catch (Throwable t) { - indexShard.warmerService().logger().warn("failed to warm-up global ordinals for [{}]", t, fieldMapper.names().name()); + indexShard.warmerService().logger().warn("failed to warm-up global ordinals for [{}]", t, fieldMapper.names().fullName()); } finally { latch.countDown(); } diff --git a/src/main/java/org/elasticsearch/search/highlight/HighlightUtils.java b/src/main/java/org/elasticsearch/search/highlight/HighlightUtils.java index c6620d247bf..d4ee0343708 100644 --- a/src/main/java/org/elasticsearch/search/highlight/HighlightUtils.java +++ b/src/main/java/org/elasticsearch/search/highlight/HighlightUtils.java @@ -57,7 +57,7 @@ public final class HighlightUtils { } else { SourceLookup sourceLookup = searchContext.lookup().source(); sourceLookup.setSegmentAndDocument(hitContext.readerContext(), hitContext.docId()); - textsToHighlight = sourceLookup.extractRawValues(hitContext.getSourcePath(mapper.names().sourcePath())); + textsToHighlight = sourceLookup.extractRawValues(hitContext.getSourcePath(mapper.names().fullName())); } assert textsToHighlight != null; return textsToHighlight; diff --git a/src/main/java/org/elasticsearch/search/highlight/vectorhighlight/SourceScoreOrderFragmentsBuilder.java b/src/main/java/org/elasticsearch/search/highlight/vectorhighlight/SourceScoreOrderFragmentsBuilder.java index b6d8fb0d7a4..89fa156d5f7 100644 --- a/src/main/java/org/elasticsearch/search/highlight/vectorhighlight/SourceScoreOrderFragmentsBuilder.java +++ b/src/main/java/org/elasticsearch/search/highlight/vectorhighlight/SourceScoreOrderFragmentsBuilder.java @@ -60,7 +60,7 @@ public class SourceScoreOrderFragmentsBuilder extends ScoreOrderFragmentsBuilder SourceLookup sourceLookup = searchContext.lookup().source(); sourceLookup.setSegmentAndDocument((LeafReaderContext) reader.getContext(), docId); - List values = sourceLookup.extractRawValues(hitContext.getSourcePath(mapper.names().sourcePath())); + List values = sourceLookup.extractRawValues(hitContext.getSourcePath(mapper.names().fullName())); Field[] fields = new Field[values.size()]; for (int i = 0; i < values.size(); i++) { fields[i] = new Field(mapper.names().indexName(), values.get(i).toString(), TextField.TYPE_NOT_STORED); diff --git a/src/main/java/org/elasticsearch/search/highlight/vectorhighlight/SourceSimpleFragmentsBuilder.java b/src/main/java/org/elasticsearch/search/highlight/vectorhighlight/SourceSimpleFragmentsBuilder.java index 9b4a1c62c11..d196cccd06f 100644 --- a/src/main/java/org/elasticsearch/search/highlight/vectorhighlight/SourceSimpleFragmentsBuilder.java +++ b/src/main/java/org/elasticsearch/search/highlight/vectorhighlight/SourceSimpleFragmentsBuilder.java @@ -56,7 +56,7 @@ public class SourceSimpleFragmentsBuilder extends SimpleFragmentsBuilder { SourceLookup sourceLookup = searchContext.lookup().source(); sourceLookup.setSegmentAndDocument((LeafReaderContext) reader.getContext(), docId); - List values = sourceLookup.extractRawValues(hitContext.getSourcePath(mapper.names().sourcePath())); + List values = sourceLookup.extractRawValues(hitContext.getSourcePath(mapper.names().fullName())); if (values.isEmpty()) { return EMPTY_FIELDS; } diff --git a/src/test/java/org/elasticsearch/index/mapper/externalvalues/ExternalMapper.java b/src/test/java/org/elasticsearch/index/mapper/externalvalues/ExternalMapper.java index 17815ebf9d1..c799b03a93a 100755 --- a/src/test/java/org/elasticsearch/index/mapper/externalvalues/ExternalMapper.java +++ b/src/test/java/org/elasticsearch/index/mapper/externalvalues/ExternalMapper.java @@ -236,7 +236,7 @@ public class ExternalMapper extends AbstractFieldMapper { @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { - builder.startObject(name()); + builder.startObject(names().shortName()); builder.field("type", mapperName); multiFields.toXContent(builder, params); builder.endObject(); diff --git a/src/test/java/org/elasticsearch/search/suggest/completion/CompletionPostingsFormatTest.java b/src/test/java/org/elasticsearch/search/suggest/completion/CompletionPostingsFormatTest.java index 632eadb5cfd..32e9d30f82f 100644 --- a/src/test/java/org/elasticsearch/search/suggest/completion/CompletionPostingsFormatTest.java +++ b/src/test/java/org/elasticsearch/search/suggest/completion/CompletionPostingsFormatTest.java @@ -306,7 +306,7 @@ public class CompletionPostingsFormatTest extends ElasticsearchTestCase { assertThat(reader.leaves().size(), equalTo(1)); assertThat(reader.leaves().get(0).reader().numDocs(), equalTo(weights.length)); LeafReaderContext atomicReaderContext = reader.leaves().get(0); - Terms luceneTerms = atomicReaderContext.reader().terms(mapper.name()); + Terms luceneTerms = atomicReaderContext.reader().terms(mapper.names().fullName()); Lookup lookup = ((Completion090PostingsFormat.CompletionTerms) luceneTerms).getLookup(mapper, new CompletionSuggestionContext(null)); reader.close(); writer.close();