From d8d86668771d4ee5362872208c13afb26f6979f4 Mon Sep 17 00:00:00 2001 From: Adrien Grand Date: Wed, 16 Dec 2015 19:41:34 +0100 Subject: [PATCH] Remove `index_name` back compat. Since 2.0 we enforce that fields have the same full and index names. So in 3.x we can remove the ability to have different names on the same field. --- .../classic/MapperQueryParser.java | 6 +- .../analyze/TransportAnalyzeAction.java | 4 +- .../TransportGetFieldMappingsIndexAction.java | 12 +- .../org/elasticsearch/index/IndexService.java | 8 +- .../PerFieldMappingPostingFormatCodec.java | 2 +- .../index/fielddata/IndexFieldData.java | 2 +- .../index/fielddata/IndexFieldDataCache.java | 5 +- .../fielddata/IndexFieldDataService.java | 25 ++-- .../index/fielddata/ShardFieldData.java | 13 +- .../BytesRefFieldComparatorSource.java | 2 +- .../DoubleValuesComparatorSource.java | 2 +- .../FloatValuesComparatorSource.java | 2 +- .../LongValuesComparatorSource.java | 2 +- .../ordinals/GlobalOrdinalsBuilder.java | 6 +- .../GlobalOrdinalsIndexFieldData.java | 10 +- .../InternalGlobalOrdinalsIndexFieldData.java | 4 +- .../AbstractGeoPointDVIndexFieldData.java | 15 +- .../plain/AbstractIndexFieldData.java | 15 +- .../plain/AbstractIndexGeoPointFieldData.java | 5 +- .../plain/AbstractIndexOrdinalsFieldData.java | 7 +- .../plain/BinaryDVIndexFieldData.java | 7 +- .../plain/BytesBinaryDVIndexFieldData.java | 11 +- .../plain/DisabledIndexFieldData.java | 9 +- .../plain/DocValuesIndexFieldData.java | 23 ++-- .../plain/GeoPointArrayIndexFieldData.java | 8 +- .../fielddata/plain/IndexIndexFieldData.java | 6 +- .../plain/PagedBytesIndexFieldData.java | 14 +- .../plain/ParentChildIndexFieldData.java | 11 +- .../plain/SortedNumericDVIndexFieldData.java | 5 +- .../SortedSetDVOrdinalsIndexFieldData.java | 11 +- .../index/fieldvisitor/FieldsVisitor.java | 4 +- .../fieldvisitor/SingleFieldsVisitor.java | 2 +- .../index/mapper/DocumentFieldMappers.java | 16 +-- .../index/mapper/FieldMapper.java | 32 +---- .../index/mapper/FieldTypeLookup.java | 89 ++---------- .../index/mapper/MappedFieldType.java | 129 +++++------------- .../index/mapper/MapperService.java | 34 +---- .../index/mapper/core/BinaryFieldMapper.java | 8 +- .../index/mapper/core/BooleanFieldMapper.java | 4 +- .../index/mapper/core/ByteFieldMapper.java | 10 +- .../mapper/core/CompletionFieldMapper.java | 16 +-- .../index/mapper/core/DateFieldMapper.java | 14 +- .../index/mapper/core/DoubleFieldMapper.java | 10 +- .../index/mapper/core/FloatFieldMapper.java | 10 +- .../index/mapper/core/IntegerFieldMapper.java | 10 +- .../index/mapper/core/LongFieldMapper.java | 10 +- .../index/mapper/core/NumberFieldMapper.java | 6 +- .../index/mapper/core/ShortFieldMapper.java | 10 +- .../index/mapper/core/StringFieldMapper.java | 10 +- .../mapper/core/TokenCountFieldMapper.java | 2 +- .../index/mapper/core/TypeParsers.java | 5 +- .../mapper/geo/BaseGeoPointFieldMapper.java | 10 +- .../index/mapper/geo/GeoPointFieldMapper.java | 2 +- .../mapper/geo/GeoPointFieldMapperLegacy.java | 10 +- .../index/mapper/geo/GeoShapeFieldMapper.java | 24 ++-- .../index/mapper/internal/AllFieldMapper.java | 6 +- .../internal/FieldNamesFieldMapper.java | 6 +- .../index/mapper/internal/IdFieldMapper.java | 6 +- .../mapper/internal/IndexFieldMapper.java | 6 +- .../mapper/internal/ParentFieldMapper.java | 16 +-- .../mapper/internal/RoutingFieldMapper.java | 8 +- .../mapper/internal/SourceFieldMapper.java | 4 +- .../index/mapper/internal/TTLFieldMapper.java | 2 +- .../mapper/internal/TimestampFieldMapper.java | 6 +- .../mapper/internal/TypeFieldMapper.java | 8 +- .../index/mapper/internal/UidFieldMapper.java | 4 +- .../mapper/internal/VersionFieldMapper.java | 2 +- .../index/mapper/ip/IpFieldMapper.java | 6 +- .../percolator/QueriesLoaderCollector.java | 2 +- .../index/query/CommonTermsQueryBuilder.java | 2 +- .../index/query/ExistsQueryBuilder.java | 2 +- .../query/FieldMaskingSpanQueryBuilder.java | 2 +- .../query/GeoBoundingBoxQueryBuilder.java | 2 +- .../index/query/GeoDistanceQueryBuilder.java | 2 +- .../query/GeoDistanceRangeQueryBuilder.java | 2 +- .../index/query/GeoPolygonQueryBuilder.java | 2 +- .../index/query/MoreLikeThisQueryBuilder.java | 2 +- .../index/query/QueryShardContext.java | 4 +- .../index/query/SimpleQueryStringBuilder.java | 2 +- .../index/query/SpanTermQueryBuilder.java | 2 +- .../index/query/TermsQueryBuilder.java | 2 +- .../index/query/WildcardQueryBuilder.java | 2 +- .../functionscore/DecayFunctionBuilder.java | 4 +- .../FieldValueFactorFunctionBuilder.java | 2 +- .../random/RandomScoreFunctionBuilder.java | 2 +- .../index/search/MatchQuery.java | 2 +- .../index/search/MultiMatchQuery.java | 2 +- .../search/geo/GeoDistanceRangeQuery.java | 8 +- .../index/search/geo/GeoPolygonQuery.java | 8 +- .../geo/InMemoryGeoBoundingBoxQuery.java | 4 +- .../geo/IndexedGeoBoundingBoxQuery.java | 2 +- .../index/similarity/SimilarityService.java | 2 +- .../index/termvectors/TermVectorsService.java | 6 +- .../cache/IndicesFieldDataCache.java | 19 ++- .../cache/IndicesFieldDataCacheListener.java | 5 +- .../indices/ttl/IndicesTTLService.java | 2 +- .../percolator/PercolateContext.java | 7 +- .../percolator/PercolatorService.java | 2 +- .../percolator/QueryCollector.java | 2 +- .../elasticsearch/search/SearchService.java | 18 +-- .../bucket/children/ChildrenParser.java | 2 +- .../support/ValuesSourceParser.java | 2 +- .../FieldDataFieldsFetchSubPhase.java | 2 +- .../highlight/FastVectorHighlighter.java | 6 +- .../search/highlight/HighlightUtils.java | 6 +- .../search/highlight/PlainHighlighter.java | 6 +- .../search/highlight/PostingsHighlighter.java | 2 +- .../FragmentBuilderHelper.java | 2 +- .../SourceScoreOrderFragmentsBuilder.java | 4 +- .../SourceSimpleFragmentsBuilder.java | 4 +- .../search/internal/DefaultSearchContext.java | 9 +- .../internal/FilteredSearchContext.java | 5 - .../search/internal/SearchContext.java | 4 +- .../search/lookup/FieldLookup.java | 4 +- .../search/lookup/LeafDocLookup.java | 4 +- .../search/lookup/LeafFieldsLookup.java | 6 +- .../search/sort/SortParseElement.java | 2 +- .../completion/CompletionSuggestParser.java | 4 +- .../completion/CompletionSuggester.java | 2 +- .../suggest/phrase/PhraseSuggestParser.java | 4 +- .../index/fielddata/FieldDataCacheTests.java | 6 +- .../fielddata/IndexFieldDataServiceTests.java | 11 +- .../NoOrdinalsStringFieldDataTests.java | 5 +- .../mapper/DocumentFieldMapperTests.java | 4 +- .../index/mapper/FieldTypeLookupTests.java | 90 +++--------- .../index/mapper/FieldTypeTestCase.java | 4 +- .../CompletionFieldMapperTests.java | 12 +- .../ExternalMetadataMapper.java | 2 +- .../internal/FieldNamesFieldMapperTests.java | 2 +- .../internal/ParentFieldMapperTests.java | 12 +- .../mapper/simple/SimpleMapperTests.java | 14 +- .../FieldMaskingSpanQueryBuilderTests.java | 2 +- .../index/query/RangeQueryBuilderTests.java | 2 +- .../functionscore/FunctionScoreTests.java | 9 +- .../index/shard/IndexShardTests.java | 2 +- .../CategoryContextMappingTests.java | 8 +- .../completion/GeoContextMappingTests.java | 8 +- .../expression/CountMethodValueSource.java | 2 +- .../expression/DateMethodValueSource.java | 2 +- .../ExpressionScriptEngineService.java | 2 +- .../expression/FieldDataValueSource.java | 2 +- .../messy/tests/GeoShapeIntegrationTests.java | 4 +- .../attachments/EncryptedDocMapperTests.java | 48 +++---- ...anguageDetectionAttachmentMapperTests.java | 4 +- .../attachments/MetadataMapperTests.java | 20 +-- .../SimpleAttachmentMapperTests.java | 40 ++---- .../mapper/attachments/StandaloneRunner.java | 2 +- .../mapper/attachments/VariousDocTests.java | 6 +- .../index/mapper/size/SizeFieldMapper.java | 2 +- .../elasticsearch/test/TestSearchContext.java | 13 +- 150 files changed, 533 insertions(+), 823 deletions(-) diff --git a/core/src/main/java/org/apache/lucene/queryparser/classic/MapperQueryParser.java b/core/src/main/java/org/apache/lucene/queryparser/classic/MapperQueryParser.java index 744950ed4f6..89eedce09d8 100644 --- a/core/src/main/java/org/apache/lucene/queryparser/classic/MapperQueryParser.java +++ b/core/src/main/java/org/apache/lucene/queryparser/classic/MapperQueryParser.java @@ -226,7 +226,7 @@ public class MapperQueryParser extends QueryParser { } } if (query == null) { - query = super.getFieldQuery(currentFieldType.names().indexName(), queryText, quoted); + query = super.getFieldQuery(currentFieldType.name(), queryText, quoted); } return query; } @@ -466,7 +466,7 @@ public class MapperQueryParser extends QueryParser { query = currentFieldType.prefixQuery(termStr, multiTermRewriteMethod, context); } if (query == null) { - query = getPossiblyAnalyzedPrefixQuery(currentFieldType.names().indexName(), termStr); + query = getPossiblyAnalyzedPrefixQuery(currentFieldType.name(), termStr); } return query; } @@ -592,7 +592,7 @@ public class MapperQueryParser extends QueryParser { if (!settings.forceAnalyzer()) { setAnalyzer(context.getSearchAnalyzer(currentFieldType)); } - indexedNameField = currentFieldType.names().indexName(); + indexedNameField = currentFieldType.name(); return getPossiblyAnalyzedWildcardQuery(indexedNameField, termStr); } return getPossiblyAnalyzedWildcardQuery(indexedNameField, termStr); diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/analyze/TransportAnalyzeAction.java b/core/src/main/java/org/elasticsearch/action/admin/indices/analyze/TransportAnalyzeAction.java index f9f3321e511..0541ac31505 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/indices/analyze/TransportAnalyzeAction.java +++ b/core/src/main/java/org/elasticsearch/action/admin/indices/analyze/TransportAnalyzeAction.java @@ -126,13 +126,13 @@ public class TransportAnalyzeAction extends TransportSingleShardAction remainingFieldMappers = newLinkedList(allFieldMappers); for (Iterator it = remainingFieldMappers.iterator(); it.hasNext(); ) { final FieldMapper fieldMapper = it.next(); - if (Regex.simpleMatch(field, fieldMapper.fieldType().names().fullName())) { - addFieldMapper(fieldMapper.fieldType().names().fullName(), fieldMapper, fieldMappings, request.includeDefaults()); + if (Regex.simpleMatch(field, fieldMapper.fieldType().name())) { + addFieldMapper(fieldMapper.fieldType().name(), fieldMapper, fieldMappings, request.includeDefaults()); it.remove(); } } for (Iterator it = remainingFieldMappers.iterator(); it.hasNext(); ) { final FieldMapper fieldMapper = it.next(); - if (Regex.simpleMatch(field, fieldMapper.fieldType().names().indexName())) { - addFieldMapper(fieldMapper.fieldType().names().indexName(), fieldMapper, fieldMappings, request.includeDefaults()); + if (Regex.simpleMatch(field, fieldMapper.fieldType().name())) { + addFieldMapper(fieldMapper.fieldType().name(), fieldMapper, fieldMappings, request.includeDefaults()); it.remove(); } } @@ -214,7 +214,7 @@ public class TransportGetFieldMappingsIndexAction extends TransportSingleShardAc builder.startObject(); fieldMapper.toXContent(builder, includeDefaults ? includeDefaultsParams : ToXContent.EMPTY_PARAMS); builder.endObject(); - fieldMappings.put(field, new FieldMappingMetaData(fieldMapper.fieldType().names().fullName(), builder.bytes())); + fieldMappings.put(field, new FieldMappingMetaData(fieldMapper.fieldType().name(), builder.bytes())); } catch (IOException e) { throw new ElasticsearchException("failed to serialize XContent of field [" + field + "]", e); } diff --git a/core/src/main/java/org/elasticsearch/index/IndexService.java b/core/src/main/java/org/elasticsearch/index/IndexService.java index 21d688edd4c..100b8b7ae81 100644 --- a/core/src/main/java/org/elasticsearch/index/IndexService.java +++ b/core/src/main/java/org/elasticsearch/index/IndexService.java @@ -459,21 +459,21 @@ public final class IndexService extends AbstractIndexComponent implements IndexC } @Override - public void onCache(ShardId shardId, MappedFieldType.Names fieldNames, FieldDataType fieldDataType, Accountable ramUsage) { + public void onCache(ShardId shardId, String fieldName, FieldDataType fieldDataType, Accountable ramUsage) { if (shardId != null) { final IndexShard shard = indexService.getShardOrNull(shardId.id()); if (shard != null) { - shard.fieldData().onCache(shardId, fieldNames, fieldDataType, ramUsage); + shard.fieldData().onCache(shardId, fieldName, fieldDataType, ramUsage); } } } @Override - public void onRemoval(ShardId shardId, MappedFieldType.Names fieldNames, FieldDataType fieldDataType, boolean wasEvicted, long sizeInBytes) { + public void onRemoval(ShardId shardId, String fieldName, FieldDataType fieldDataType, boolean wasEvicted, long sizeInBytes) { if (shardId != null) { final IndexShard shard = indexService.getShardOrNull(shardId.id()); if (shard != null) { - shard.fieldData().onRemoval(shardId, fieldNames, fieldDataType, wasEvicted, sizeInBytes); + shard.fieldData().onRemoval(shardId, fieldName, fieldDataType, wasEvicted, sizeInBytes); } } } diff --git a/core/src/main/java/org/elasticsearch/index/codec/PerFieldMappingPostingFormatCodec.java b/core/src/main/java/org/elasticsearch/index/codec/PerFieldMappingPostingFormatCodec.java index 2c23f947475..7663a322be6 100644 --- a/core/src/main/java/org/elasticsearch/index/codec/PerFieldMappingPostingFormatCodec.java +++ b/core/src/main/java/org/elasticsearch/index/codec/PerFieldMappingPostingFormatCodec.java @@ -54,7 +54,7 @@ public class PerFieldMappingPostingFormatCodec extends Lucene54Codec { @Override public PostingsFormat getPostingsFormatForField(String field) { - final MappedFieldType indexName = mapperService.indexName(field); + final MappedFieldType indexName = mapperService.fullName(field); if (indexName == null) { logger.warn("no index mapper found for field: [{}] returning default postings format", field); } else if (indexName instanceof CompletionFieldMapper.CompletionFieldType) { diff --git a/core/src/main/java/org/elasticsearch/index/fielddata/IndexFieldData.java b/core/src/main/java/org/elasticsearch/index/fielddata/IndexFieldData.java index fb01a374d2f..ffa23bf56e4 100644 --- a/core/src/main/java/org/elasticsearch/index/fielddata/IndexFieldData.java +++ b/core/src/main/java/org/elasticsearch/index/fielddata/IndexFieldData.java @@ -80,7 +80,7 @@ public interface IndexFieldData extends IndexCompone /** * The field name. */ - MappedFieldType.Names getFieldNames(); + String getFieldName(); /** * The field data type. diff --git a/core/src/main/java/org/elasticsearch/index/fielddata/IndexFieldDataCache.java b/core/src/main/java/org/elasticsearch/index/fielddata/IndexFieldDataCache.java index f14a0a6314b..7640a9be200 100644 --- a/core/src/main/java/org/elasticsearch/index/fielddata/IndexFieldDataCache.java +++ b/core/src/main/java/org/elasticsearch/index/fielddata/IndexFieldDataCache.java @@ -22,7 +22,6 @@ package org.elasticsearch.index.fielddata; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.util.Accountable; -import org.elasticsearch.index.mapper.MappedFieldType; import org.elasticsearch.index.shard.ShardId; /** @@ -49,12 +48,12 @@ public interface IndexFieldDataCache { /** * Called after the fielddata is loaded during the cache phase */ - void onCache(ShardId shardId, MappedFieldType.Names fieldNames, FieldDataType fieldDataType, Accountable ramUsage); + void onCache(ShardId shardId, String fieldName, FieldDataType fieldDataType, Accountable ramUsage); /** * Called after the fielddata is unloaded */ - void onRemoval(ShardId shardId, MappedFieldType.Names fieldNames, FieldDataType fieldDataType, boolean wasEvicted, long sizeInBytes); + void onRemoval(ShardId shardId, String fieldName, FieldDataType fieldDataType, boolean wasEvicted, long sizeInBytes); } class None implements IndexFieldDataCache { diff --git a/core/src/main/java/org/elasticsearch/index/fielddata/IndexFieldDataService.java b/core/src/main/java/org/elasticsearch/index/fielddata/IndexFieldDataService.java index 39cd710c4ad..8ac0bda2f0b 100644 --- a/core/src/main/java/org/elasticsearch/index/fielddata/IndexFieldDataService.java +++ b/core/src/main/java/org/elasticsearch/index/fielddata/IndexFieldDataService.java @@ -34,7 +34,6 @@ import org.elasticsearch.index.fielddata.plain.IndexIndexFieldData; import org.elasticsearch.index.fielddata.plain.PagedBytesIndexFieldData; import org.elasticsearch.index.fielddata.plain.ParentChildIndexFieldData; import org.elasticsearch.index.mapper.MappedFieldType; -import org.elasticsearch.index.mapper.MappedFieldType.Names; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.core.BooleanFieldMapper; import org.elasticsearch.index.mapper.internal.IndexFieldMapper; @@ -61,7 +60,7 @@ public class IndexFieldDataService extends AbstractIndexComponent implements Clo public static final String FIELDDATA_CACHE_VALUE_NODE = "node"; private static final IndexFieldData.Builder MISSING_DOC_VALUES_BUILDER = (indexProperties, fieldType, cache, breakerService, mapperService1) -> { - throw new IllegalStateException("Can't load fielddata on [" + fieldType.names().fullName() + throw new IllegalStateException("Can't load fielddata on [" + fieldType.name() + "] of index [" + indexProperties.getIndex().getName() + "] because fielddata is unsupported on fields of type [" + fieldType.fieldDataType().getType() + "]. Use doc values instead."); }; @@ -148,11 +147,11 @@ public class IndexFieldDataService extends AbstractIndexComponent implements Clo private final MapperService mapperService; private static final IndexFieldDataCache.Listener DEFAULT_NOOP_LISTENER = new IndexFieldDataCache.Listener() { @Override - public void onCache(ShardId shardId, Names fieldNames, FieldDataType fieldDataType, Accountable ramUsage) { + public void onCache(ShardId shardId, String fieldName, FieldDataType fieldDataType, Accountable ramUsage) { } @Override - public void onRemoval(ShardId shardId, Names fieldNames, FieldDataType fieldDataType, boolean wasEvicted, long sizeInBytes) { + public void onRemoval(ShardId shardId, String fieldName, FieldDataType fieldDataType, boolean wasEvicted, long sizeInBytes) { } }; private volatile IndexFieldDataCache.Listener listener = DEFAULT_NOOP_LISTENER; @@ -195,22 +194,22 @@ public class IndexFieldDataService extends AbstractIndexComponent implements Clo @SuppressWarnings("unchecked") public > IFD getForField(MappedFieldType fieldType) { - final Names fieldNames = fieldType.names(); + final String fieldName = fieldType.name(); final FieldDataType type = fieldType.fieldDataType(); if (type == null) { - throw new IllegalArgumentException("found no fielddata type for field [" + fieldNames.fullName() + "]"); + throw new IllegalArgumentException("found no fielddata type for field [" + fieldName + "]"); } final boolean docValues = fieldType.hasDocValues(); IndexFieldData.Builder builder = null; String format = type.getFormat(indexSettings.getSettings()); if (format != null && FieldDataType.DOC_VALUES_FORMAT_VALUE.equals(format) && !docValues) { - logger.warn("field [" + fieldNames.fullName() + "] has no doc values, will use default field data format"); + logger.warn("field [" + fieldName + "] has no doc values, will use default field data format"); format = null; } if (format != null) { builder = buildersByTypeAndFormat.get(Tuple.tuple(type.getType(), format)); if (builder == null) { - logger.warn("failed to find format [" + format + "] for field [" + fieldNames.fullName() + "], will use default"); + logger.warn("failed to find format [" + format + "] for field [" + fieldName + "], will use default"); } } if (builder == null && docValues) { @@ -220,24 +219,24 @@ public class IndexFieldDataService extends AbstractIndexComponent implements Clo builder = buildersByType.get(type.getType()); } if (builder == null) { - throw new IllegalArgumentException("failed to find field data builder for field " + fieldNames.fullName() + ", and type " + type.getType()); + throw new IllegalArgumentException("failed to find field data builder for field " + fieldName + ", and type " + type.getType()); } IndexFieldDataCache cache; synchronized (this) { - cache = fieldDataCaches.get(fieldNames.indexName()); + cache = fieldDataCaches.get(fieldName); if (cache == null) { // we default to node level cache, which in turn defaults to be unbounded // this means changing the node level settings is simple, just set the bounds there String cacheType = type.getSettings().get("cache", indexSettings.getSettings().get(FIELDDATA_CACHE_KEY, FIELDDATA_CACHE_VALUE_NODE)); if (FIELDDATA_CACHE_VALUE_NODE.equals(cacheType)) { - cache = indicesFieldDataCache.buildIndexFieldDataCache(listener, index(), fieldNames, type); + cache = indicesFieldDataCache.buildIndexFieldDataCache(listener, index(), fieldName, type); } else if ("none".equals(cacheType)){ cache = new IndexFieldDataCache.None(); } else { - throw new IllegalArgumentException("cache type not supported [" + cacheType + "] for field [" + fieldNames.fullName() + "]"); + throw new IllegalArgumentException("cache type not supported [" + cacheType + "] for field [" + fieldName + "]"); } - fieldDataCaches.put(fieldNames.indexName(), cache); + fieldDataCaches.put(fieldName, cache); } } diff --git a/core/src/main/java/org/elasticsearch/index/fielddata/ShardFieldData.java b/core/src/main/java/org/elasticsearch/index/fielddata/ShardFieldData.java index e646364ef13..bb31df75348 100644 --- a/core/src/main/java/org/elasticsearch/index/fielddata/ShardFieldData.java +++ b/core/src/main/java/org/elasticsearch/index/fielddata/ShardFieldData.java @@ -24,7 +24,6 @@ import org.apache.lucene.util.Accountable; import org.elasticsearch.common.metrics.CounterMetric; import org.elasticsearch.common.regex.Regex; import org.elasticsearch.common.util.concurrent.ConcurrentCollections; -import org.elasticsearch.index.mapper.MappedFieldType; import org.elasticsearch.index.shard.ShardId; import java.util.Map; @@ -52,16 +51,15 @@ public class ShardFieldData implements IndexFieldDataCache.Listener { } @Override - public void onCache(ShardId shardId, MappedFieldType.Names fieldNames, FieldDataType fieldDataType, Accountable ramUsage) { + public void onCache(ShardId shardId, String fieldName, FieldDataType fieldDataType, Accountable ramUsage) { totalMetric.inc(ramUsage.ramBytesUsed()); - String keyFieldName = fieldNames.indexName(); - CounterMetric total = perFieldTotals.get(keyFieldName); + CounterMetric total = perFieldTotals.get(fieldName); if (total != null) { total.inc(ramUsage.ramBytesUsed()); } else { total = new CounterMetric(); total.inc(ramUsage.ramBytesUsed()); - CounterMetric prev = perFieldTotals.putIfAbsent(keyFieldName, total); + CounterMetric prev = perFieldTotals.putIfAbsent(fieldName, total); if (prev != null) { prev.inc(ramUsage.ramBytesUsed()); } @@ -69,15 +67,14 @@ public class ShardFieldData implements IndexFieldDataCache.Listener { } @Override - public void onRemoval(ShardId shardId, MappedFieldType.Names fieldNames, FieldDataType fieldDataType, boolean wasEvicted, long sizeInBytes) { + public void onRemoval(ShardId shardId, String fieldName, FieldDataType fieldDataType, boolean wasEvicted, long sizeInBytes) { if (wasEvicted) { evictionsMetric.inc(); } if (sizeInBytes != -1) { totalMetric.dec(sizeInBytes); - String keyFieldName = fieldNames.indexName(); - CounterMetric total = perFieldTotals.get(keyFieldName); + CounterMetric total = perFieldTotals.get(fieldName); if (total != null) { total.dec(sizeInBytes); } diff --git a/core/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/BytesRefFieldComparatorSource.java b/core/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/BytesRefFieldComparatorSource.java index 2ae3f950409..51f8f2b42bd 100644 --- a/core/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/BytesRefFieldComparatorSource.java +++ b/core/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/BytesRefFieldComparatorSource.java @@ -80,7 +80,7 @@ public class BytesRefFieldComparatorSource extends IndexFieldData.XFieldComparat @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { - assert indexFieldData == null || fieldname.equals(indexFieldData.getFieldNames().indexName()); + assert indexFieldData == null || fieldname.equals(indexFieldData.getFieldName()); final boolean sortMissingLast = sortMissingLast(missingValue) ^ reversed; final BytesRef missingBytes = (BytesRef) missingObject(missingValue, reversed); diff --git a/core/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/DoubleValuesComparatorSource.java b/core/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/DoubleValuesComparatorSource.java index 5391345e793..4684399a23d 100644 --- a/core/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/DoubleValuesComparatorSource.java +++ b/core/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/DoubleValuesComparatorSource.java @@ -65,7 +65,7 @@ public class DoubleValuesComparatorSource extends IndexFieldData.XFieldComparato @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { - assert indexFieldData == null || fieldname.equals(indexFieldData.getFieldNames().indexName()); + assert indexFieldData == null || fieldname.equals(indexFieldData.getFieldName()); final double dMissingValue = (Double) missingObject(missingValue, reversed); // NOTE: it's important to pass null as a missing value in the constructor so that diff --git a/core/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/FloatValuesComparatorSource.java b/core/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/FloatValuesComparatorSource.java index 15628513e80..ba9b031cede 100644 --- a/core/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/FloatValuesComparatorSource.java +++ b/core/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/FloatValuesComparatorSource.java @@ -57,7 +57,7 @@ public class FloatValuesComparatorSource extends IndexFieldData.XFieldComparator @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { - assert indexFieldData == null || fieldname.equals(indexFieldData.getFieldNames().indexName()); + assert indexFieldData == null || fieldname.equals(indexFieldData.getFieldName()); final float dMissingValue = (Float) missingObject(missingValue, reversed); // NOTE: it's important to pass null as a missing value in the constructor so that diff --git a/core/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/LongValuesComparatorSource.java b/core/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/LongValuesComparatorSource.java index fe84f8e8840..b2fd25e5445 100644 --- a/core/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/LongValuesComparatorSource.java +++ b/core/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/LongValuesComparatorSource.java @@ -56,7 +56,7 @@ public class LongValuesComparatorSource extends IndexFieldData.XFieldComparatorS @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { - assert indexFieldData == null || fieldname.equals(indexFieldData.getFieldNames().indexName()); + assert indexFieldData == null || fieldname.equals(indexFieldData.getFieldName()); final Long dMissingValue = (Long) missingObject(missingValue, reversed); // NOTE: it's important to pass null as a missing value in the constructor so that diff --git a/core/src/main/java/org/elasticsearch/index/fielddata/ordinals/GlobalOrdinalsBuilder.java b/core/src/main/java/org/elasticsearch/index/fielddata/ordinals/GlobalOrdinalsBuilder.java index 38b36a640cf..dc5041d24ef 100644 --- a/core/src/main/java/org/elasticsearch/index/fielddata/ordinals/GlobalOrdinalsBuilder.java +++ b/core/src/main/java/org/elasticsearch/index/fielddata/ordinals/GlobalOrdinalsBuilder.java @@ -64,12 +64,12 @@ public enum GlobalOrdinalsBuilder { if (logger.isDebugEnabled()) { logger.debug( "Global-ordinals[{}][{}] took {} ms", - indexFieldData.getFieldNames().fullName(), + indexFieldData.getFieldName(), ordinalMap.getValueCount(), TimeValue.nsecToMSec(System.nanoTime() - startTimeNS) ); } - return new InternalGlobalOrdinalsIndexFieldData(indexSettings, indexFieldData.getFieldNames(), + return new InternalGlobalOrdinalsIndexFieldData(indexSettings, indexFieldData.getFieldName(), indexFieldData.getFieldDataType(), atomicFD, ordinalMap, memorySizeInBytes ); } @@ -103,7 +103,7 @@ public enum GlobalOrdinalsBuilder { subs[i] = atomicFD[i].getOrdinalsValues(); } final OrdinalMap ordinalMap = OrdinalMap.build(null, subs, PackedInts.DEFAULT); - return new InternalGlobalOrdinalsIndexFieldData(indexSettings, indexFieldData.getFieldNames(), + return new InternalGlobalOrdinalsIndexFieldData(indexSettings, indexFieldData.getFieldName(), indexFieldData.getFieldDataType(), atomicFD, ordinalMap, 0 ); } diff --git a/core/src/main/java/org/elasticsearch/index/fielddata/ordinals/GlobalOrdinalsIndexFieldData.java b/core/src/main/java/org/elasticsearch/index/fielddata/ordinals/GlobalOrdinalsIndexFieldData.java index 4a8bd78bb4e..5e1a2b57401 100644 --- a/core/src/main/java/org/elasticsearch/index/fielddata/ordinals/GlobalOrdinalsIndexFieldData.java +++ b/core/src/main/java/org/elasticsearch/index/fielddata/ordinals/GlobalOrdinalsIndexFieldData.java @@ -40,13 +40,13 @@ import java.util.Collections; */ public abstract class GlobalOrdinalsIndexFieldData extends AbstractIndexComponent implements IndexOrdinalsFieldData, Accountable { - private final MappedFieldType.Names fieldNames; + private final String fieldName; private final FieldDataType fieldDataType; private final long memorySizeInBytes; - protected GlobalOrdinalsIndexFieldData(IndexSettings indexSettings, MappedFieldType.Names fieldNames, FieldDataType fieldDataType, long memorySizeInBytes) { + protected GlobalOrdinalsIndexFieldData(IndexSettings indexSettings, String fieldName, FieldDataType fieldDataType, long memorySizeInBytes) { super(indexSettings); - this.fieldNames = fieldNames; + this.fieldName = fieldName; this.fieldDataType = fieldDataType; this.memorySizeInBytes = memorySizeInBytes; } @@ -67,8 +67,8 @@ public abstract class GlobalOrdinalsIndexFieldData extends AbstractIndexComponen } @Override - public MappedFieldType.Names getFieldNames() { - return fieldNames; + public String getFieldName() { + return fieldName; } @Override diff --git a/core/src/main/java/org/elasticsearch/index/fielddata/ordinals/InternalGlobalOrdinalsIndexFieldData.java b/core/src/main/java/org/elasticsearch/index/fielddata/ordinals/InternalGlobalOrdinalsIndexFieldData.java index fc1b6db9758..297c8b0f30c 100644 --- a/core/src/main/java/org/elasticsearch/index/fielddata/ordinals/InternalGlobalOrdinalsIndexFieldData.java +++ b/core/src/main/java/org/elasticsearch/index/fielddata/ordinals/InternalGlobalOrdinalsIndexFieldData.java @@ -37,8 +37,8 @@ final class InternalGlobalOrdinalsIndexFieldData extends GlobalOrdinalsIndexFiel private final Atomic[] atomicReaders; - InternalGlobalOrdinalsIndexFieldData(IndexSettings indexSettings, MappedFieldType.Names fieldNames, FieldDataType fieldDataType, AtomicOrdinalsFieldData[] segmentAfd, OrdinalMap ordinalMap, long memorySizeInBytes) { - super(indexSettings, fieldNames, fieldDataType, memorySizeInBytes); + InternalGlobalOrdinalsIndexFieldData(IndexSettings indexSettings, String fieldName, FieldDataType fieldDataType, AtomicOrdinalsFieldData[] segmentAfd, OrdinalMap ordinalMap, long memorySizeInBytes) { + super(indexSettings, fieldName, fieldDataType, memorySizeInBytes); this.atomicReaders = new Atomic[segmentAfd.length]; for (int i = 0; i < segmentAfd.length; i++) { atomicReaders[i] = new Atomic(segmentAfd[i], ordinalMap, i); diff --git a/core/src/main/java/org/elasticsearch/index/fielddata/plain/AbstractGeoPointDVIndexFieldData.java b/core/src/main/java/org/elasticsearch/index/fielddata/plain/AbstractGeoPointDVIndexFieldData.java index 237f147ebf0..3d4b6536b6c 100644 --- a/core/src/main/java/org/elasticsearch/index/fielddata/plain/AbstractGeoPointDVIndexFieldData.java +++ b/core/src/main/java/org/elasticsearch/index/fielddata/plain/AbstractGeoPointDVIndexFieldData.java @@ -32,7 +32,6 @@ import org.elasticsearch.index.fielddata.IndexFieldData.XFieldComparatorSource.N import org.elasticsearch.index.fielddata.IndexFieldDataCache; import org.elasticsearch.index.fielddata.IndexGeoPointFieldData; import org.elasticsearch.index.mapper.MappedFieldType; -import org.elasticsearch.index.mapper.MappedFieldType.Names; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.indices.breaker.CircuitBreakerService; import org.elasticsearch.search.MultiValueMode; @@ -41,8 +40,8 @@ import java.io.IOException; public abstract class AbstractGeoPointDVIndexFieldData extends DocValuesIndexFieldData implements IndexGeoPointFieldData { - AbstractGeoPointDVIndexFieldData(Index index, Names fieldNames, FieldDataType fieldDataType) { - super(index, fieldNames, fieldDataType); + AbstractGeoPointDVIndexFieldData(Index index, String fieldName, FieldDataType fieldDataType) { + super(index, fieldName, fieldDataType); } @Override @@ -56,8 +55,8 @@ public abstract class AbstractGeoPointDVIndexFieldData extends DocValuesIndexFie public static class GeoPointDVIndexFieldData extends AbstractGeoPointDVIndexFieldData { final boolean indexCreatedBefore2x; - public GeoPointDVIndexFieldData(Index index, Names fieldNames, FieldDataType fieldDataType, final boolean indexCreatedBefore2x) { - super(index, fieldNames, fieldDataType); + public GeoPointDVIndexFieldData(Index index, String fieldName, FieldDataType fieldDataType, final boolean indexCreatedBefore2x) { + super(index, fieldName, fieldDataType); this.indexCreatedBefore2x = indexCreatedBefore2x; } @@ -65,9 +64,9 @@ public abstract class AbstractGeoPointDVIndexFieldData extends DocValuesIndexFie public AtomicGeoPointFieldData load(LeafReaderContext context) { try { if (indexCreatedBefore2x) { - return new GeoPointLegacyDVAtomicFieldData(DocValues.getBinary(context.reader(), fieldNames.indexName())); + return new GeoPointLegacyDVAtomicFieldData(DocValues.getBinary(context.reader(), fieldName)); } - return new GeoPointDVAtomicFieldData(DocValues.getSortedNumeric(context.reader(), fieldNames.indexName())); + return new GeoPointDVAtomicFieldData(DocValues.getSortedNumeric(context.reader(), fieldName)); } catch (IOException e) { throw new IllegalStateException("Cannot load doc values", e); } @@ -84,7 +83,7 @@ public abstract class AbstractGeoPointDVIndexFieldData extends DocValuesIndexFie public IndexFieldData build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) { // Ignore breaker - return new GeoPointDVIndexFieldData(indexSettings.getIndex(), fieldType.names(), fieldType.fieldDataType(), + return new GeoPointDVIndexFieldData(indexSettings.getIndex(), fieldType.name(), fieldType.fieldDataType(), indexSettings.getIndexVersionCreated().before(Version.V_2_2_0)); } } diff --git a/core/src/main/java/org/elasticsearch/index/fielddata/plain/AbstractIndexFieldData.java b/core/src/main/java/org/elasticsearch/index/fielddata/plain/AbstractIndexFieldData.java index 23baeede1cb..151ee92058d 100644 --- a/core/src/main/java/org/elasticsearch/index/fielddata/plain/AbstractIndexFieldData.java +++ b/core/src/main/java/org/elasticsearch/index/fielddata/plain/AbstractIndexFieldData.java @@ -31,7 +31,6 @@ import org.elasticsearch.index.fielddata.FieldDataType; import org.elasticsearch.index.fielddata.IndexFieldData; import org.elasticsearch.index.fielddata.IndexFieldDataCache; import org.elasticsearch.index.fielddata.RamAccountingTermsEnum; -import org.elasticsearch.index.mapper.MappedFieldType; import java.io.IOException; @@ -39,20 +38,20 @@ import java.io.IOException; */ public abstract class AbstractIndexFieldData extends AbstractIndexComponent implements IndexFieldData { - private final MappedFieldType.Names fieldNames; + private final String fieldName; protected final FieldDataType fieldDataType; protected final IndexFieldDataCache cache; - public AbstractIndexFieldData(IndexSettings indexSettings, MappedFieldType.Names fieldNames, FieldDataType fieldDataType, IndexFieldDataCache cache) { + public AbstractIndexFieldData(IndexSettings indexSettings, String fieldName, FieldDataType fieldDataType, IndexFieldDataCache cache) { super(indexSettings); - this.fieldNames = fieldNames; + this.fieldName = fieldName; this.fieldDataType = fieldDataType; this.cache = cache; } @Override - public MappedFieldType.Names getFieldNames() { - return this.fieldNames; + public String getFieldName() { + return this.fieldName; } @Override @@ -62,12 +61,12 @@ public abstract class AbstractIndexFieldData extends @Override public void clear() { - cache.clear(fieldNames.indexName()); + cache.clear(fieldName); } @Override public FD load(LeafReaderContext context) { - if (context.reader().getFieldInfos().fieldInfo(fieldNames.indexName()) == null) { + if (context.reader().getFieldInfos().fieldInfo(fieldName) == null) { // Some leaf readers may be wrapped and report different set of fields and use the same cache key. // If a field can't be found then it doesn't mean it isn't there, // so if a field doesn't exist then we don't cache it and just return an empty field data instance. diff --git a/core/src/main/java/org/elasticsearch/index/fielddata/plain/AbstractIndexGeoPointFieldData.java b/core/src/main/java/org/elasticsearch/index/fielddata/plain/AbstractIndexGeoPointFieldData.java index e4a043852cb..a8114c41f9b 100644 --- a/core/src/main/java/org/elasticsearch/index/fielddata/plain/AbstractIndexGeoPointFieldData.java +++ b/core/src/main/java/org/elasticsearch/index/fielddata/plain/AbstractIndexGeoPointFieldData.java @@ -31,7 +31,6 @@ import org.elasticsearch.index.fielddata.FieldDataType; import org.elasticsearch.index.fielddata.IndexFieldData.XFieldComparatorSource.Nested; import org.elasticsearch.index.fielddata.IndexFieldDataCache; import org.elasticsearch.index.fielddata.IndexGeoPointFieldData; -import org.elasticsearch.index.mapper.MappedFieldType.Names; import org.elasticsearch.search.MultiValueMode; import java.io.IOException; @@ -92,8 +91,8 @@ abstract class AbstractIndexGeoPointFieldData extends AbstractIndexFieldData groups = fieldDataType.getSettings().getGroups("filter"); frequency = groups.get("frequency"); regex = groups.get("regex"); @@ -74,7 +73,7 @@ public abstract class AbstractIndexOrdinalsFieldData extends AbstractIndexFieldD } boolean fieldFound = false; for (LeafReaderContext context : indexReader.leaves()) { - if (context.reader().getFieldInfos().fieldInfo(getFieldNames().indexName()) != null) { + if (context.reader().getFieldInfos().fieldInfo(getFieldName()) != null) { fieldFound = true; break; } diff --git a/core/src/main/java/org/elasticsearch/index/fielddata/plain/BinaryDVIndexFieldData.java b/core/src/main/java/org/elasticsearch/index/fielddata/plain/BinaryDVIndexFieldData.java index 2e03b74a41f..c2a50942566 100644 --- a/core/src/main/java/org/elasticsearch/index/fielddata/plain/BinaryDVIndexFieldData.java +++ b/core/src/main/java/org/elasticsearch/index/fielddata/plain/BinaryDVIndexFieldData.java @@ -25,18 +25,17 @@ import org.elasticsearch.index.fielddata.FieldDataType; import org.elasticsearch.index.fielddata.IndexFieldData; import org.elasticsearch.index.fielddata.IndexFieldData.XFieldComparatorSource.Nested; import org.elasticsearch.index.fielddata.fieldcomparator.BytesRefFieldComparatorSource; -import org.elasticsearch.index.mapper.MappedFieldType.Names; import org.elasticsearch.search.MultiValueMode; public class BinaryDVIndexFieldData extends DocValuesIndexFieldData implements IndexFieldData { - public BinaryDVIndexFieldData(Index index, Names fieldNames, FieldDataType fieldDataType) { - super(index, fieldNames, fieldDataType); + public BinaryDVIndexFieldData(Index index, String fieldName, FieldDataType fieldDataType) { + super(index, fieldName, fieldDataType); } @Override public BinaryDVAtomicFieldData load(LeafReaderContext context) { - return new BinaryDVAtomicFieldData(context.reader(), fieldNames.indexName()); + return new BinaryDVAtomicFieldData(context.reader(), fieldName); } @Override diff --git a/core/src/main/java/org/elasticsearch/index/fielddata/plain/BytesBinaryDVIndexFieldData.java b/core/src/main/java/org/elasticsearch/index/fielddata/plain/BytesBinaryDVIndexFieldData.java index 28fae2c6385..988ecd61d65 100644 --- a/core/src/main/java/org/elasticsearch/index/fielddata/plain/BytesBinaryDVIndexFieldData.java +++ b/core/src/main/java/org/elasticsearch/index/fielddata/plain/BytesBinaryDVIndexFieldData.java @@ -29,7 +29,6 @@ import org.elasticsearch.index.fielddata.IndexFieldData; import org.elasticsearch.index.fielddata.IndexFieldData.XFieldComparatorSource.Nested; import org.elasticsearch.index.fielddata.IndexFieldDataCache; import org.elasticsearch.index.mapper.MappedFieldType; -import org.elasticsearch.index.mapper.MappedFieldType.Names; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.indices.breaker.CircuitBreakerService; import org.elasticsearch.search.MultiValueMode; @@ -38,8 +37,8 @@ import java.io.IOException; public class BytesBinaryDVIndexFieldData extends DocValuesIndexFieldData implements IndexFieldData { - public BytesBinaryDVIndexFieldData(Index index, Names fieldNames, FieldDataType fieldDataType) { - super(index, fieldNames, fieldDataType); + public BytesBinaryDVIndexFieldData(Index index, String fieldName, FieldDataType fieldDataType) { + super(index, fieldName, fieldDataType); } @Override @@ -50,7 +49,7 @@ public class BytesBinaryDVIndexFieldData extends DocValuesIndexFieldData impleme @Override public BytesBinaryDVAtomicFieldData load(LeafReaderContext context) { try { - return new BytesBinaryDVAtomicFieldData(DocValues.getBinary(context.reader(), fieldNames.indexName())); + return new BytesBinaryDVAtomicFieldData(DocValues.getBinary(context.reader(), fieldName)); } catch (IOException e) { throw new IllegalStateException("Cannot load doc values", e); } @@ -67,8 +66,8 @@ public class BytesBinaryDVIndexFieldData extends DocValuesIndexFieldData impleme public IndexFieldData build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) { // Ignore breaker - final Names fieldNames = fieldType.names(); - return new BytesBinaryDVIndexFieldData(indexSettings.getIndex(), fieldNames, fieldType.fieldDataType()); + final String fieldName = fieldType.name(); + return new BytesBinaryDVIndexFieldData(indexSettings.getIndex(), fieldName, fieldType.fieldDataType()); } } diff --git a/core/src/main/java/org/elasticsearch/index/fielddata/plain/DisabledIndexFieldData.java b/core/src/main/java/org/elasticsearch/index/fielddata/plain/DisabledIndexFieldData.java index 859d720d072..86daaf1a252 100644 --- a/core/src/main/java/org/elasticsearch/index/fielddata/plain/DisabledIndexFieldData.java +++ b/core/src/main/java/org/elasticsearch/index/fielddata/plain/DisabledIndexFieldData.java @@ -27,7 +27,6 @@ import org.elasticsearch.index.fielddata.IndexFieldData; import org.elasticsearch.index.fielddata.IndexFieldData.XFieldComparatorSource.Nested; import org.elasticsearch.index.fielddata.IndexFieldDataCache; import org.elasticsearch.index.mapper.MappedFieldType; -import org.elasticsearch.index.mapper.MappedFieldType.Names; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.indices.breaker.CircuitBreakerService; import org.elasticsearch.search.MultiValueMode; @@ -43,12 +42,12 @@ public final class DisabledIndexFieldData extends AbstractIndexFieldData build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) { // Ignore Circuit Breaker - return new DisabledIndexFieldData(indexSettings, fieldType.names(), fieldType.fieldDataType(), cache); + return new DisabledIndexFieldData(indexSettings, fieldType.name(), fieldType.fieldDataType(), cache); } } - public DisabledIndexFieldData(IndexSettings indexSettings, Names fieldNames, FieldDataType fieldDataType, IndexFieldDataCache cache) { - super(indexSettings, fieldNames, fieldDataType, cache); + public DisabledIndexFieldData(IndexSettings indexSettings, String fieldName, FieldDataType fieldDataType, IndexFieldDataCache cache) { + super(indexSettings, fieldName, fieldDataType, cache); } @Override @@ -67,7 +66,7 @@ public final class DisabledIndexFieldData extends AbstractIndexFieldData build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) { // Ignore Circuit Breaker - final Names fieldNames = fieldType.names(); + final String fieldName = fieldType.name(); final Settings fdSettings = fieldType.fieldDataType().getSettings(); final Map filter = fdSettings.getGroups("filter"); if (filter != null && !filter.isEmpty()) { - throw new IllegalArgumentException("Doc values field data doesn't support filters [" + fieldNames.fullName() + "]"); + throw new IllegalArgumentException("Doc values field data doesn't support filters [" + fieldName + "]"); } - if (BINARY_INDEX_FIELD_NAMES.contains(fieldNames.indexName())) { + if (BINARY_INDEX_FIELD_NAMES.contains(fieldName)) { assert numericType == null; - return new BinaryDVIndexFieldData(indexSettings.getIndex(), fieldNames, fieldType.fieldDataType()); + return new BinaryDVIndexFieldData(indexSettings.getIndex(), fieldName, fieldType.fieldDataType()); } else if (numericType != null) { - return new SortedNumericDVIndexFieldData(indexSettings.getIndex(), fieldNames, numericType, fieldType.fieldDataType()); + return new SortedNumericDVIndexFieldData(indexSettings.getIndex(), fieldName, numericType, fieldType.fieldDataType()); } else { - return new SortedSetDVOrdinalsIndexFieldData(indexSettings, cache, fieldNames, breakerService, fieldType.fieldDataType()); + return new SortedSetDVOrdinalsIndexFieldData(indexSettings, cache, fieldName, breakerService, fieldType.fieldDataType()); } } diff --git a/core/src/main/java/org/elasticsearch/index/fielddata/plain/GeoPointArrayIndexFieldData.java b/core/src/main/java/org/elasticsearch/index/fielddata/plain/GeoPointArrayIndexFieldData.java index a0c0a55be71..495cc023e90 100644 --- a/core/src/main/java/org/elasticsearch/index/fielddata/plain/GeoPointArrayIndexFieldData.java +++ b/core/src/main/java/org/elasticsearch/index/fielddata/plain/GeoPointArrayIndexFieldData.java @@ -54,17 +54,17 @@ public class GeoPointArrayIndexFieldData extends AbstractIndexGeoPointFieldData @Override public IndexFieldData build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) { - return new GeoPointArrayIndexFieldData(indexSettings, fieldType.names(), fieldType.fieldDataType(), cache, + return new GeoPointArrayIndexFieldData(indexSettings, fieldType.name(), fieldType.fieldDataType(), cache, breakerService, fieldType.fieldDataType().getSettings() .getAsVersion(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).before(Version.V_2_2_0) || indexSettings.getIndexVersionCreated().before(Version.V_2_2_0)); } } - public GeoPointArrayIndexFieldData(IndexSettings indexSettings, MappedFieldType.Names fieldNames, + public GeoPointArrayIndexFieldData(IndexSettings indexSettings, String fieldName, FieldDataType fieldDataType, IndexFieldDataCache cache, CircuitBreakerService breakerService, final boolean indexCreatedBefore22) { - super(indexSettings, fieldNames, fieldDataType, cache); + super(indexSettings, fieldName, fieldDataType, cache); this.breakerService = breakerService; this.indexCreatedBefore22 = indexCreatedBefore22; } @@ -73,7 +73,7 @@ public class GeoPointArrayIndexFieldData extends AbstractIndexGeoPointFieldData public AtomicGeoPointFieldData loadDirect(LeafReaderContext context) throws Exception { LeafReader reader = context.reader(); - Terms terms = reader.terms(getFieldNames().indexName()); + Terms terms = reader.terms(getFieldName()); AtomicGeoPointFieldData data = null; // TODO: Use an actual estimator to estimate before loading. NonEstimatingEstimator estimator = new NonEstimatingEstimator(breakerService.getBreaker(CircuitBreaker.FIELDDATA)); diff --git a/core/src/main/java/org/elasticsearch/index/fielddata/plain/IndexIndexFieldData.java b/core/src/main/java/org/elasticsearch/index/fielddata/plain/IndexIndexFieldData.java index 471bea73570..f2c4fa826f1 100644 --- a/core/src/main/java/org/elasticsearch/index/fielddata/plain/IndexIndexFieldData.java +++ b/core/src/main/java/org/elasticsearch/index/fielddata/plain/IndexIndexFieldData.java @@ -46,7 +46,7 @@ public class IndexIndexFieldData extends AbstractIndexOrdinalsFieldData { @Override public IndexFieldData build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) { - return new IndexIndexFieldData(indexSettings, fieldType.names()); + return new IndexIndexFieldData(indexSettings, fieldType.name()); } } @@ -100,8 +100,8 @@ public class IndexIndexFieldData extends AbstractIndexOrdinalsFieldData { private final AtomicOrdinalsFieldData atomicFieldData; - private IndexIndexFieldData(IndexSettings indexSettings, MappedFieldType.Names names) { - super(indexSettings, names, new FieldDataType("string"), null, null); + private IndexIndexFieldData(IndexSettings indexSettings, String name) { + super(indexSettings, name, new FieldDataType("string"), null, null); atomicFieldData = new IndexAtomicFieldData(index().name()); } diff --git a/core/src/main/java/org/elasticsearch/index/fielddata/plain/PagedBytesIndexFieldData.java b/core/src/main/java/org/elasticsearch/index/fielddata/plain/PagedBytesIndexFieldData.java index cbf865a202d..ce4f5c55eac 100644 --- a/core/src/main/java/org/elasticsearch/index/fielddata/plain/PagedBytesIndexFieldData.java +++ b/core/src/main/java/org/elasticsearch/index/fielddata/plain/PagedBytesIndexFieldData.java @@ -57,13 +57,13 @@ public class PagedBytesIndexFieldData extends AbstractIndexOrdinalsFieldData { @Override public IndexOrdinalsFieldData build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) { - return new PagedBytesIndexFieldData(indexSettings, fieldType.names(), fieldType.fieldDataType(), cache, breakerService); + return new PagedBytesIndexFieldData(indexSettings, fieldType.name(), fieldType.fieldDataType(), cache, breakerService); } } - public PagedBytesIndexFieldData(IndexSettings indexSettings, MappedFieldType.Names fieldNames, + public PagedBytesIndexFieldData(IndexSettings indexSettings, String fieldName, FieldDataType fieldDataType, IndexFieldDataCache cache, CircuitBreakerService breakerService) { - super(indexSettings, fieldNames, fieldDataType, cache, breakerService); + super(indexSettings, fieldName, fieldDataType, cache, breakerService); } @Override @@ -71,8 +71,8 @@ public class PagedBytesIndexFieldData extends AbstractIndexOrdinalsFieldData { LeafReader reader = context.reader(); AtomicOrdinalsFieldData data = null; - PagedBytesEstimator estimator = new PagedBytesEstimator(context, breakerService.getBreaker(CircuitBreaker.FIELDDATA), getFieldNames().fullName()); - Terms terms = reader.terms(getFieldNames().indexName()); + PagedBytesEstimator estimator = new PagedBytesEstimator(context, breakerService.getBreaker(CircuitBreaker.FIELDDATA), getFieldName()); + Terms terms = reader.terms(getFieldName()); if (terms == null) { data = AbstractAtomicOrdinalsFieldData.empty(); estimator.afterLoad(null, data.ramBytesUsed()); @@ -167,10 +167,10 @@ public class PagedBytesIndexFieldData extends AbstractIndexOrdinalsFieldData { public long estimateStringFieldData() { try { LeafReader reader = context.reader(); - Terms terms = reader.terms(getFieldNames().indexName()); + Terms terms = reader.terms(getFieldName()); Fields fields = reader.fields(); - final Terms fieldTerms = fields.terms(getFieldNames().indexName()); + final Terms fieldTerms = fields.terms(getFieldName()); if (fieldTerms instanceof FieldReader) { final Stats stats = ((FieldReader) fieldTerms).getStats(); diff --git a/core/src/main/java/org/elasticsearch/index/fielddata/plain/ParentChildIndexFieldData.java b/core/src/main/java/org/elasticsearch/index/fielddata/plain/ParentChildIndexFieldData.java index eba523e0e2e..14d0375ba57 100644 --- a/core/src/main/java/org/elasticsearch/index/fielddata/plain/ParentChildIndexFieldData.java +++ b/core/src/main/java/org/elasticsearch/index/fielddata/plain/ParentChildIndexFieldData.java @@ -48,7 +48,6 @@ import org.elasticsearch.index.fielddata.IndexParentChildFieldData; import org.elasticsearch.index.fielddata.fieldcomparator.BytesRefFieldComparatorSource; import org.elasticsearch.index.mapper.DocumentMapper; import org.elasticsearch.index.mapper.MappedFieldType; -import org.elasticsearch.index.mapper.MappedFieldType.Names; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.internal.ParentFieldMapper; import org.elasticsearch.indices.breaker.CircuitBreakerService; @@ -75,10 +74,10 @@ public class ParentChildIndexFieldData extends AbstractIndexFieldData parentTypes; private final CircuitBreakerService breakerService; - public ParentChildIndexFieldData(IndexSettings indexSettings, MappedFieldType.Names fieldNames, + public ParentChildIndexFieldData(IndexSettings indexSettings, String fieldName, FieldDataType fieldDataType, IndexFieldDataCache cache, MapperService mapperService, CircuitBreakerService breakerService) { - super(indexSettings, fieldNames, fieldDataType, cache); + super(indexSettings, fieldName, fieldDataType, cache); this.breakerService = breakerService; Set parentTypes = new HashSet<>(); for (DocumentMapper mapper : mapperService.docMappers(false)) { @@ -147,7 +146,7 @@ public class ParentChildIndexFieldData extends AbstractIndexFieldData> entry : fields().entrySet()) { - MappedFieldType fieldType = mapperService.indexName(entry.getKey()); + MappedFieldType fieldType = mapperService.fullName(entry.getKey()); if (fieldType == null) { continue; } @@ -112,7 +112,7 @@ public class FieldsVisitor extends StoredFieldVisitor { if (fieldMapper == null) { // it's possible index name doesn't match field name (legacy feature) for (FieldMapper mapper : documentMapper.mappers()) { - if (mapper.fieldType().names().indexName().equals(indexName)) { + if (mapper.fieldType().name().equals(indexName)) { fieldMapper = mapper; break; } diff --git a/core/src/main/java/org/elasticsearch/index/fieldvisitor/SingleFieldsVisitor.java b/core/src/main/java/org/elasticsearch/index/fieldvisitor/SingleFieldsVisitor.java index d628ee4e961..a9880d59f65 100644 --- a/core/src/main/java/org/elasticsearch/index/fieldvisitor/SingleFieldsVisitor.java +++ b/core/src/main/java/org/elasticsearch/index/fieldvisitor/SingleFieldsVisitor.java @@ -69,7 +69,7 @@ public class SingleFieldsVisitor extends FieldsVisitor { if (fieldsValues == null) { return; } - List fieldValues = fieldsValues.get(fieldType.names().indexName()); + List fieldValues = fieldsValues.get(fieldType.name()); if (fieldValues == null) { return; } diff --git a/core/src/main/java/org/elasticsearch/index/mapper/DocumentFieldMappers.java b/core/src/main/java/org/elasticsearch/index/mapper/DocumentFieldMappers.java index 90da570bbe6..57f2ff40530 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/DocumentFieldMappers.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/DocumentFieldMappers.java @@ -58,9 +58,9 @@ public final class DocumentFieldMappers implements Iterable { for (FieldMapper mapper : mappers) { fieldMappers.put(mapper.name(), mapper); MappedFieldType fieldType = mapper.fieldType(); - put(indexAnalyzers, fieldType.names().indexName(), fieldType.indexAnalyzer(), defaultIndex); - put(searchAnalyzers, fieldType.names().indexName(), fieldType.searchAnalyzer(), defaultSearch); - put(searchQuoteAnalyzers, fieldType.names().indexName(), fieldType.searchQuoteAnalyzer(), defaultSearchQuote); + put(indexAnalyzers, fieldType.name(), fieldType.indexAnalyzer(), defaultIndex); + put(searchAnalyzers, fieldType.name(), fieldType.searchAnalyzer(), defaultSearch); + put(searchQuoteAnalyzers, fieldType.name(), fieldType.searchQuoteAnalyzer(), defaultSearchQuote); } this.fieldMappers = Collections.unmodifiableMap(fieldMappers); this.indexAnalyzer = new FieldNameAnalyzer(indexAnalyzers); @@ -76,10 +76,10 @@ public final class DocumentFieldMappers implements Iterable { public Collection simpleMatchToFullName(String pattern) { Set fields = new HashSet<>(); for (FieldMapper fieldMapper : this) { - if (Regex.simpleMatch(pattern, fieldMapper.fieldType().names().fullName())) { - fields.add(fieldMapper.fieldType().names().fullName()); - } else if (Regex.simpleMatch(pattern, fieldMapper.fieldType().names().indexName())) { - fields.add(fieldMapper.fieldType().names().fullName()); + if (Regex.simpleMatch(pattern, fieldMapper.fieldType().name())) { + fields.add(fieldMapper.fieldType().name()); + } else if (Regex.simpleMatch(pattern, fieldMapper.fieldType().name())) { + fields.add(fieldMapper.fieldType().name()); } } return fields; @@ -91,7 +91,7 @@ public final class DocumentFieldMappers implements Iterable { return fieldMapper; } for (FieldMapper otherFieldMapper : this) { - if (otherFieldMapper.fieldType().names().indexName().equals(name)) { + if (otherFieldMapper.fieldType().name().equals(name)) { return otherFieldMapper; } } diff --git a/core/src/main/java/org/elasticsearch/index/mapper/FieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/FieldMapper.java index 9c77a416bf1..3ab0ec86303 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/FieldMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/FieldMapper.java @@ -217,31 +217,12 @@ public abstract class FieldMapper extends Mapper implements Cloneable { return builder; } - protected MappedFieldType.Names buildNames(BuilderContext context) { - return new MappedFieldType.Names(buildIndexName(context), buildIndexNameClean(context), buildFullName(context)); - } - - protected String buildIndexName(BuilderContext context) { - if (context.indexCreatedVersion().onOrAfter(Version.V_2_0_0_beta1)) { - return buildFullName(context); - } - String actualIndexName = indexName == null ? name : indexName; - return context.path().pathAsText(actualIndexName); - } - - protected String buildIndexNameClean(BuilderContext context) { - if (context.indexCreatedVersion().onOrAfter(Version.V_2_0_0_beta1)) { - return buildFullName(context); - } - return indexName == null ? name : indexName; - } - protected String buildFullName(BuilderContext context) { return context.path().pathAsText(name); } protected void setupFieldType(BuilderContext context) { - fieldType.setNames(buildNames(context)); + fieldType.setName(buildFullName(context)); if (fieldType.indexAnalyzer() == null && fieldType.tokenized() == false && fieldType.indexOptions() != IndexOptions.NONE) { fieldType.setIndexAnalyzer(Lucene.KEYWORD_ANALYZER); fieldType.setSearchAnalyzer(Lucene.KEYWORD_ANALYZER); @@ -288,7 +269,7 @@ public abstract class FieldMapper extends Mapper implements Cloneable { @Override public String name() { - return fieldType().names().fullName(); + return fieldType().name(); } public MappedFieldType fieldType() { @@ -318,7 +299,7 @@ public abstract class FieldMapper extends Mapper implements Cloneable { context.doc().add(field); } } catch (Exception e) { - throw new MapperParsingException("failed to parse [" + fieldType().names().fullName() + "]", e); + throw new MapperParsingException("failed to parse [" + fieldType().name() + "]", e); } multiFields.parse(this, context); return null; @@ -367,7 +348,7 @@ public abstract class FieldMapper extends Mapper implements Cloneable { if (mergeWith instanceof FieldMapper) { mergedType = ((FieldMapper) mergeWith).contentType(); } - throw new IllegalArgumentException("mapper [" + fieldType().names().fullName() + "] of different type, current_type [" + contentType() + "], merged_type [" + mergedType + "]"); + throw new IllegalArgumentException("mapper [" + fieldType().name() + "] of different type, current_type [" + contentType() + "], merged_type [" + mergedType + "]"); } FieldMapper fieldMergeWith = (FieldMapper) mergeWith; multiFields = multiFields.merge(fieldMergeWith.multiFields); @@ -379,7 +360,7 @@ public abstract class FieldMapper extends Mapper implements Cloneable { @Override public FieldMapper updateFieldType(Map fullNameToFieldType) { - final MappedFieldType newFieldType = fullNameToFieldType.get(fieldType.names().fullName()); + final MappedFieldType newFieldType = fullNameToFieldType.get(fieldType.name()); if (newFieldType == null) { throw new IllegalStateException(); } @@ -404,9 +385,6 @@ public abstract class FieldMapper extends Mapper implements Cloneable { protected void doXContentBody(XContentBuilder builder, boolean includeDefaults, Params params) throws IOException { builder.field("type", contentType()); - if (indexCreatedBefore2x && (includeDefaults || !simpleName().equals(fieldType().names().originalIndexName()))) { - builder.field("index_name", fieldType().names().originalIndexName()); - } if (includeDefaults || fieldType().boost() != 1.0f) { builder.field("boost", fieldType().boost()); diff --git a/core/src/main/java/org/elasticsearch/index/mapper/FieldTypeLookup.java b/core/src/main/java/org/elasticsearch/index/mapper/FieldTypeLookup.java index e06b4e799ed..5e9378e2f55 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/FieldTypeLookup.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/FieldTypeLookup.java @@ -42,29 +42,17 @@ class FieldTypeLookup implements Iterable { /** Full field name to types containing a mapping for this full name. */ final CopyOnWriteHashMap> fullNameToTypes; - /** Index field name to field type */ - final CopyOnWriteHashMap indexNameToFieldType; - - /** Index field name to types containing a mapping for this index name. */ - final CopyOnWriteHashMap> indexNameToTypes; - /** Create a new empty instance. */ public FieldTypeLookup() { fullNameToFieldType = new CopyOnWriteHashMap<>(); fullNameToTypes = new CopyOnWriteHashMap<>(); - indexNameToFieldType = new CopyOnWriteHashMap<>(); - indexNameToTypes = new CopyOnWriteHashMap<>(); } private FieldTypeLookup( CopyOnWriteHashMap fullName, - CopyOnWriteHashMap> fullNameToTypes, - CopyOnWriteHashMap indexName, - CopyOnWriteHashMap> indexNameToTypes) { + CopyOnWriteHashMap> fullNameToTypes) { this.fullNameToFieldType = fullName; this.fullNameToTypes = fullNameToTypes; - this.indexNameToFieldType = indexName; - this.indexNameToTypes = indexNameToTypes; } private static CopyOnWriteHashMap> addType(CopyOnWriteHashMap> map, String key, String type) { @@ -97,31 +85,21 @@ class FieldTypeLookup implements Iterable { CopyOnWriteHashMap fullName = this.fullNameToFieldType; CopyOnWriteHashMap> fullNameToTypes = this.fullNameToTypes; - CopyOnWriteHashMap indexName = this.indexNameToFieldType; - CopyOnWriteHashMap> indexNameToTypes = this.indexNameToTypes; for (FieldMapper fieldMapper : fieldMappers) { MappedFieldType fieldType = fieldMapper.fieldType(); - MappedFieldType fullNameFieldType = fullName.get(fieldType.names().fullName()); - MappedFieldType indexNameFieldType = indexName.get(fieldType.names().indexName()); - - if (fullNameFieldType != null && indexNameFieldType != null && fullNameFieldType != indexNameFieldType) { - // this new field bridges between two existing field names (a full and index name), which we cannot support - throw new IllegalStateException("insane mappings found. field " + fieldType.names().fullName() + " maps across types to field " + fieldType.names().indexName()); - } + MappedFieldType fullNameFieldType = fullName.get(fieldType.name()); // is the update even legal? checkCompatibility(type, fieldMapper, updateAllTypes); - if (fieldType != fullNameFieldType || fieldType != indexNameFieldType) { - fullName = fullName.copyAndPut(fieldType.names().fullName(), fieldMapper.fieldType()); - indexName = indexName.copyAndPut(fieldType.names().indexName(), fieldMapper.fieldType()); + if (fieldType != fullNameFieldType) { + fullName = fullName.copyAndPut(fieldType.name(), fieldMapper.fieldType()); } - fullNameToTypes = addType(fullNameToTypes, fieldType.names().fullName(), type); - indexNameToTypes = addType(indexNameToTypes, fieldType.names().indexName(), type); + fullNameToTypes = addType(fullNameToTypes, fieldType.name(), type); } - return new FieldTypeLookup(fullName, fullNameToTypes, indexName, indexNameToTypes); + return new FieldTypeLookup(fullName, fullNameToTypes); } private static boolean beStrict(String type, Set types, boolean updateAllTypes) { @@ -142,26 +120,14 @@ class FieldTypeLookup implements Iterable { * If updateAllTypes is true, only basic compatibility is checked. */ private void checkCompatibility(String type, FieldMapper fieldMapper, boolean updateAllTypes) { - MappedFieldType fieldType = fullNameToFieldType.get(fieldMapper.fieldType().names().fullName()); + MappedFieldType fieldType = fullNameToFieldType.get(fieldMapper.fieldType().name()); if (fieldType != null) { List conflicts = new ArrayList<>(); - final Set types = fullNameToTypes.get(fieldMapper.fieldType().names().fullName()); + final Set types = fullNameToTypes.get(fieldMapper.fieldType().name()); boolean strict = beStrict(type, types, updateAllTypes); fieldType.checkCompatibility(fieldMapper.fieldType(), conflicts, strict); if (conflicts.isEmpty() == false) { - throw new IllegalArgumentException("Mapper for [" + fieldMapper.fieldType().names().fullName() + "] conflicts with existing mapping in other types:\n" + conflicts.toString()); - } - } - - // field type for the index name must be compatible too - fieldType = indexNameToFieldType.get(fieldMapper.fieldType().names().indexName()); - if (fieldType != null) { - List conflicts = new ArrayList<>(); - final Set types = indexNameToTypes.get(fieldMapper.fieldType().names().indexName()); - boolean strict = beStrict(type, types, updateAllTypes); - fieldType.checkCompatibility(fieldMapper.fieldType(), conflicts, strict); - if (conflicts.isEmpty() == false) { - throw new IllegalArgumentException("Mapper for [" + fieldMapper.fieldType().names().fullName() + "] conflicts with mapping with the same index name in other types" + conflicts.toString()); + throw new IllegalArgumentException("Mapper for [" + fieldMapper.fieldType().name() + "] conflicts with existing mapping in other types:\n" + conflicts.toString()); } } } @@ -180,45 +146,16 @@ class FieldTypeLookup implements Iterable { return types; } - /** Returns the field type for the given index name */ - public MappedFieldType getByIndexName(String field) { - return indexNameToFieldType.get(field); - } - - /** Get the set of types that have a mapping for the given field. */ - public Set getTypesByIndexName(String field) { - Set types = indexNameToTypes.get(field); - if (types == null) { - types = Collections.emptySet(); - } - return types; - } - - /** - * Returns a list of the index names of a simple match regex like pattern against full name and index name. - */ - public Collection simpleMatchToIndexNames(String pattern) { - Set fields = new HashSet<>(); - for (MappedFieldType fieldType : this) { - if (Regex.simpleMatch(pattern, fieldType.names().fullName())) { - fields.add(fieldType.names().indexName()); - } else if (Regex.simpleMatch(pattern, fieldType.names().indexName())) { - fields.add(fieldType.names().indexName()); - } - } - return fields; - } - /** * Returns a list of the full names of a simple match regex like pattern against full name and index name. */ public Collection simpleMatchToFullName(String pattern) { Set fields = new HashSet<>(); for (MappedFieldType fieldType : this) { - if (Regex.simpleMatch(pattern, fieldType.names().fullName())) { - fields.add(fieldType.names().fullName()); - } else if (Regex.simpleMatch(pattern, fieldType.names().indexName())) { - fields.add(fieldType.names().fullName()); + if (Regex.simpleMatch(pattern, fieldType.name())) { + fields.add(fieldType.name()); + } else if (Regex.simpleMatch(pattern, fieldType.name())) { + fields.add(fieldType.name()); } } return fields; diff --git a/core/src/main/java/org/elasticsearch/index/mapper/MappedFieldType.java b/core/src/main/java/org/elasticsearch/index/mapper/MappedFieldType.java index c1383817c79..5f8049b55fb 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/MappedFieldType.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/MappedFieldType.java @@ -53,68 +53,6 @@ import java.util.Objects; */ public abstract class MappedFieldType extends FieldType { - public static class Names { - - private final String indexName; - - private final String originalIndexName; - - private final String fullName; - - public Names(String name) { - this(name, name, name); - } - - public Names(String indexName, String originalIndexName, String fullName) { - this.indexName = indexName; - this.originalIndexName = originalIndexName; - this.fullName = fullName; - } - - /** - * The indexed name of the field. This is the name under which we will - * store it in the index. - */ - public String indexName() { - return indexName; - } - - /** - * The original index name, before any "path" modifications performed on it. - */ - public String originalIndexName() { - return originalIndexName; - } - - /** - * The full name, including dot path. - */ - public String fullName() { - return fullName; - } - - @Override - public boolean equals(Object o) { - if (o == null || getClass() != o.getClass()) return false; - - Names names = (Names) o; - - if (!fullName.equals(names.fullName)) return false; - if (!indexName.equals(names.indexName)) return false; - if (!originalIndexName.equals(names.originalIndexName)) return false; - - return true; - } - - @Override - public int hashCode() { - int result = indexName.hashCode(); - result = 31 * result + originalIndexName.hashCode(); - result = 31 * result + fullName.hashCode(); - return result; - } - } - public enum Loading { LAZY { @Override @@ -155,7 +93,7 @@ public abstract class MappedFieldType extends FieldType { } } - private Names names; + private String name; private float boost; // TODO: remove this docvalues flag and use docValuesType private boolean docValues; @@ -170,7 +108,7 @@ public abstract class MappedFieldType extends FieldType { protected MappedFieldType(MappedFieldType ref) { super(ref); - this.names = ref.names(); + this.name = ref.name(); this.boost = ref.boost(); this.docValues = ref.hasDocValues(); this.indexAnalyzer = ref.indexAnalyzer(); @@ -214,7 +152,7 @@ public abstract class MappedFieldType extends FieldType { return boost == fieldType.boost && docValues == fieldType.docValues && - Objects.equals(names, fieldType.names) && + Objects.equals(name, fieldType.name) && Objects.equals(indexAnalyzer, fieldType.indexAnalyzer) && Objects.equals(searchAnalyzer, fieldType.searchAnalyzer) && Objects.equals(searchQuoteAnalyzer(), fieldType.searchQuoteAnalyzer()) && @@ -226,7 +164,7 @@ public abstract class MappedFieldType extends FieldType { @Override public int hashCode() { - return Objects.hash(super.hashCode(), names, boost, docValues, indexAnalyzer, searchAnalyzer, searchQuoteAnalyzer, + return Objects.hash(super.hashCode(), name, boost, docValues, indexAnalyzer, searchAnalyzer, searchQuoteAnalyzer, similarity == null ? null : similarity.name(), normsLoading, fieldDataType, nullValue, nullValueAsString); } @@ -238,7 +176,7 @@ public abstract class MappedFieldType extends FieldType { /** Checks this type is the same type as other. Adds a conflict if they are different. */ private final void checkTypeName(MappedFieldType other) { if (typeName().equals(other.typeName()) == false) { - throw new IllegalArgumentException("mapper [" + names().fullName() + "] cannot be changed from type [" + typeName() + "] to [" + other.typeName() + "]"); + throw new IllegalArgumentException("mapper [" + name + "] cannot be changed from type [" + typeName() + "] to [" + other.typeName() + "]"); } else if (getClass() != other.getClass()) { throw new IllegalStateException("Type names equal for class " + getClass().getSimpleName() + " and " + other.getClass().getSimpleName()); } @@ -256,71 +194,68 @@ public abstract class MappedFieldType extends FieldType { boolean mergeWithIndexed = other.indexOptions() != IndexOptions.NONE; // TODO: should be validating if index options go "up" (but "down" is ok) if (indexed != mergeWithIndexed || tokenized() != other.tokenized()) { - conflicts.add("mapper [" + names().fullName() + "] has different [index] values"); + conflicts.add("mapper [" + name() + "] has different [index] values"); } if (stored() != other.stored()) { - conflicts.add("mapper [" + names().fullName() + "] has different [store] values"); + conflicts.add("mapper [" + name() + "] has different [store] values"); } if (hasDocValues() == false && other.hasDocValues()) { // don't add conflict if this mapper has doc values while the mapper to merge doesn't since doc values are implicitly set // when the doc_values field data format is configured - conflicts.add("mapper [" + names().fullName() + "] has different [doc_values] values, cannot change from disabled to enabled"); + conflicts.add("mapper [" + name() + "] has different [doc_values] values, cannot change from disabled to enabled"); } if (omitNorms() && !other.omitNorms()) { - conflicts.add("mapper [" + names().fullName() + "] has different [omit_norms] values, cannot change from disable to enabled"); + conflicts.add("mapper [" + name() + "] has different [omit_norms] values, cannot change from disable to enabled"); } if (storeTermVectors() != other.storeTermVectors()) { - conflicts.add("mapper [" + names().fullName() + "] has different [store_term_vector] values"); + conflicts.add("mapper [" + name() + "] has different [store_term_vector] values"); } if (storeTermVectorOffsets() != other.storeTermVectorOffsets()) { - conflicts.add("mapper [" + names().fullName() + "] has different [store_term_vector_offsets] values"); + conflicts.add("mapper [" + name() + "] has different [store_term_vector_offsets] values"); } if (storeTermVectorPositions() != other.storeTermVectorPositions()) { - conflicts.add("mapper [" + names().fullName() + "] has different [store_term_vector_positions] values"); + conflicts.add("mapper [" + name() + "] has different [store_term_vector_positions] values"); } if (storeTermVectorPayloads() != other.storeTermVectorPayloads()) { - conflicts.add("mapper [" + names().fullName() + "] has different [store_term_vector_payloads] values"); + conflicts.add("mapper [" + name() + "] has different [store_term_vector_payloads] values"); } // null and "default"-named index analyzers both mean the default is used if (indexAnalyzer() == null || "default".equals(indexAnalyzer().name())) { if (other.indexAnalyzer() != null && "default".equals(other.indexAnalyzer().name()) == false) { - conflicts.add("mapper [" + names().fullName() + "] has different [analyzer]"); + conflicts.add("mapper [" + name() + "] has different [analyzer]"); } } else if (other.indexAnalyzer() == null || "default".equals(other.indexAnalyzer().name())) { - conflicts.add("mapper [" + names().fullName() + "] has different [analyzer]"); + conflicts.add("mapper [" + name() + "] has different [analyzer]"); } else if (indexAnalyzer().name().equals(other.indexAnalyzer().name()) == false) { - conflicts.add("mapper [" + names().fullName() + "] has different [analyzer]"); + conflicts.add("mapper [" + name() + "] has different [analyzer]"); } - if (!names().indexName().equals(other.names().indexName())) { - conflicts.add("mapper [" + names().fullName() + "] has different [index_name]"); - } if (Objects.equals(similarity(), other.similarity()) == false) { - conflicts.add("mapper [" + names().fullName() + "] has different [similarity]"); + conflicts.add("mapper [" + name() + "] has different [similarity]"); } if (strict) { if (omitNorms() != other.omitNorms()) { - conflicts.add("mapper [" + names().fullName() + "] is used by multiple types. Set update_all_types to true to update [omit_norms] across all types."); + conflicts.add("mapper [" + name() + "] is used by multiple types. Set update_all_types to true to update [omit_norms] across all types."); } if (boost() != other.boost()) { - conflicts.add("mapper [" + names().fullName() + "] is used by multiple types. Set update_all_types to true to update [boost] across all types."); + conflicts.add("mapper [" + name() + "] is used by multiple types. Set update_all_types to true to update [boost] across all types."); } if (normsLoading() != other.normsLoading()) { - conflicts.add("mapper [" + names().fullName() + "] is used by multiple types. Set update_all_types to true to update [norms.loading] across all types."); + conflicts.add("mapper [" + name() + "] is used by multiple types. Set update_all_types to true to update [norms.loading] across all types."); } if (Objects.equals(searchAnalyzer(), other.searchAnalyzer()) == false) { - conflicts.add("mapper [" + names().fullName() + "] is used by multiple types. Set update_all_types to true to update [search_analyzer] across all types."); + conflicts.add("mapper [" + name() + "] is used by multiple types. Set update_all_types to true to update [search_analyzer] across all types."); } if (Objects.equals(searchQuoteAnalyzer(), other.searchQuoteAnalyzer()) == false) { - conflicts.add("mapper [" + names().fullName() + "] is used by multiple types. Set update_all_types to true to update [search_quote_analyzer] across all types."); + conflicts.add("mapper [" + name() + "] is used by multiple types. Set update_all_types to true to update [search_quote_analyzer] across all types."); } if (Objects.equals(fieldDataType(), other.fieldDataType()) == false) { - conflicts.add("mapper [" + names().fullName() + "] is used by multiple types. Set update_all_types to true to update [fielddata] across all types."); + conflicts.add("mapper [" + name() + "] is used by multiple types. Set update_all_types to true to update [fielddata] across all types."); } if (Objects.equals(nullValue(), other.nullValue()) == false) { - conflicts.add("mapper [" + names().fullName() + "] is used by multiple types. Set update_all_types to true to update [null_value] across all types."); + conflicts.add("mapper [" + name() + "] is used by multiple types. Set update_all_types to true to update [null_value] across all types."); } } } @@ -333,13 +268,13 @@ public abstract class MappedFieldType extends FieldType { return true; } - public Names names() { - return names; + public String name() { + return name; } - public void setNames(Names names) { + public void setName(String name) { checkIfFrozen(); - this.names = names; + this.name = name; } public float boost() { @@ -456,7 +391,7 @@ public abstract class MappedFieldType extends FieldType { /** Creates a term associated with the field of this mapper for the given value */ protected Term createTerm(Object value) { - return new Term(names().indexName(), indexedValueForSearch(value)); + return new Term(name(), indexedValueForSearch(value)); } public Query termQuery(Object value, @Nullable QueryShardContext context) { @@ -468,11 +403,11 @@ public abstract class MappedFieldType extends FieldType { for (int i = 0; i < bytesRefs.length; i++) { bytesRefs[i] = indexedValueForSearch(values.get(i)); } - return new TermsQuery(names.indexName(), bytesRefs); + return new TermsQuery(name(), bytesRefs); } public Query rangeQuery(Object lowerTerm, Object upperTerm, boolean includeLower, boolean includeUpper) { - return new TermRangeQuery(names().indexName(), + return new TermRangeQuery(name(), lowerTerm == null ? null : indexedValueForSearch(lowerTerm), upperTerm == null ? null : indexedValueForSearch(upperTerm), includeLower, includeUpper); @@ -492,7 +427,7 @@ public abstract class MappedFieldType extends FieldType { public Query regexpQuery(String value, int flags, int maxDeterminizedStates, @Nullable MultiTermQuery.RewriteMethod method, @Nullable QueryShardContext context) { if (numericType() != null) { - throw new QueryShardException(context, "Cannot use regular expression to filter numeric field [" + names.fullName + "]"); + throw new QueryShardException(context, "Cannot use regular expression to filter numeric field [" + name + "]"); } RegexpQuery query = new RegexpQuery(createTerm(value), flags, maxDeterminizedStates); diff --git a/core/src/main/java/org/elasticsearch/index/mapper/MapperService.java b/core/src/main/java/org/elasticsearch/index/mapper/MapperService.java index afaaca1b1ca..59724913bad 100755 --- a/core/src/main/java/org/elasticsearch/index/mapper/MapperService.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/MapperService.java @@ -551,15 +551,6 @@ public class MapperService extends AbstractIndexComponent implements Closeable { } } - /** - * Returns an {@link MappedFieldType} which has the given index name. - * - * If multiple types have fields with the same index name, the first is returned. - */ - public MappedFieldType indexName(String indexName) { - return fieldTypes.getByIndexName(indexName); - } - /** * Returns the {@link MappedFieldType} for the give fullName. * @@ -578,32 +569,13 @@ public class MapperService extends AbstractIndexComponent implements Closeable { // no wildcards return Collections.singletonList(pattern); } - return fieldTypes.simpleMatchToIndexNames(pattern); + return fieldTypes.simpleMatchToFullName(pattern); } - // TODO: remove this since the underlying index names are now the same across all types - public Collection simpleMatchToIndexNames(String pattern, @Nullable String[] types) { - return simpleMatchToIndexNames(pattern); - } - - // TODO: remove types param, since the object mapper must be the same across all types - public ObjectMapper getObjectMapper(String name, @Nullable String[] types) { + public ObjectMapper getObjectMapper(String name) { return fullPathObjectMappers.get(name); } - public MappedFieldType smartNameFieldType(String smartName) { - MappedFieldType fieldType = fullName(smartName); - if (fieldType != null) { - return fieldType; - } - return indexName(smartName); - } - - // TODO: remove this since the underlying index names are now the same across all types - public MappedFieldType smartNameFieldType(String smartName, @Nullable String[] types) { - return smartNameFieldType(smartName); - } - /** * Given a type (eg. long, string, ...), return an anonymous field mapper that can be used for search operations. */ @@ -697,7 +669,7 @@ public class MapperService extends AbstractIndexComponent implements Closeable { @Override protected Analyzer getWrappedAnalyzer(String fieldName) { - MappedFieldType fieldType = smartNameFieldType(fieldName); + MappedFieldType fieldType = fullName(fieldName); if (fieldType != null) { Analyzer analyzer = extractAnalyzer.apply(fieldType); if (analyzer != null) { diff --git a/core/src/main/java/org/elasticsearch/index/mapper/core/BinaryFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/core/BinaryFieldMapper.java index 4fe0eb166c4..3c80106c4f0 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/core/BinaryFieldMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/core/BinaryFieldMapper.java @@ -170,14 +170,14 @@ public class BinaryFieldMapper extends FieldMapper { return; } if (fieldType().stored()) { - fields.add(new Field(fieldType().names().indexName(), value, fieldType())); + fields.add(new Field(fieldType().name(), value, fieldType())); } if (fieldType().hasDocValues()) { - CustomBinaryDocValuesField field = (CustomBinaryDocValuesField) context.doc().getByKey(fieldType().names().indexName()); + CustomBinaryDocValuesField field = (CustomBinaryDocValuesField) context.doc().getByKey(fieldType().name()); if (field == null) { - field = new CustomBinaryDocValuesField(fieldType().names().indexName(), value); - context.doc().addWithKey(fieldType().names().indexName(), field); + field = new CustomBinaryDocValuesField(fieldType().name(), value); + context.doc().addWithKey(fieldType().name(), field); } else { field.add(value); } diff --git a/core/src/main/java/org/elasticsearch/index/mapper/core/BooleanFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/core/BooleanFieldMapper.java index e381bc9c60b..d5440f227f4 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/core/BooleanFieldMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/core/BooleanFieldMapper.java @@ -222,9 +222,9 @@ public class BooleanFieldMapper extends FieldMapper { if (value == null) { return; } - fields.add(new Field(fieldType().names().indexName(), value ? "T" : "F", fieldType())); + fields.add(new Field(fieldType().name(), value ? "T" : "F", fieldType())); if (fieldType().hasDocValues()) { - fields.add(new SortedNumericDocValuesField(fieldType().names().indexName(), value ? 1 : 0)); + fields.add(new SortedNumericDocValuesField(fieldType().name(), value ? 1 : 0)); } } diff --git a/core/src/main/java/org/elasticsearch/index/mapper/core/ByteFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/core/ByteFieldMapper.java index 9346ebf6b42..fdc50c25034 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/core/ByteFieldMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/core/ByteFieldMapper.java @@ -161,7 +161,7 @@ public class ByteFieldMapper extends NumberFieldMapper { @Override public Query rangeQuery(Object lowerTerm, Object upperTerm, boolean includeLower, boolean includeUpper) { - return NumericRangeQuery.newIntRange(names().indexName(), numericPrecisionStep(), + return NumericRangeQuery.newIntRange(name(), numericPrecisionStep(), lowerTerm == null ? null : (int)parseValue(lowerTerm), upperTerm == null ? null : (int)parseValue(upperTerm), includeLower, includeUpper); @@ -171,7 +171,7 @@ public class ByteFieldMapper extends NumberFieldMapper { public Query fuzzyQuery(Object value, Fuzziness fuzziness, int prefixLength, int maxExpansions, boolean transpositions) { byte iValue = parseValue(value); byte iSim = fuzziness.asByte(); - return NumericRangeQuery.newIntRange(names().indexName(), numericPrecisionStep(), + return NumericRangeQuery.newIntRange(name(), numericPrecisionStep(), iValue - iSim, iValue + iSim, true, true); @@ -238,7 +238,7 @@ public class ByteFieldMapper extends NumberFieldMapper { value = ((Number) externalValue).byteValue(); } if (context.includeInAll(includeInAll, this)) { - context.allEntries().addText(fieldType().names().fullName(), Byte.toString(value), boost); + context.allEntries().addText(fieldType().name(), Byte.toString(value), boost); } } else { XContentParser parser = context.parser(); @@ -249,7 +249,7 @@ public class ByteFieldMapper extends NumberFieldMapper { } value = fieldType().nullValue(); if (fieldType().nullValueAsString() != null && (context.includeInAll(includeInAll, this))) { - context.allEntries().addText(fieldType().names().fullName(), fieldType().nullValueAsString(), boost); + context.allEntries().addText(fieldType().name(), fieldType().nullValueAsString(), boost); } } else if (parser.currentToken() == XContentParser.Token.START_OBJECT) { XContentParser.Token token; @@ -278,7 +278,7 @@ public class ByteFieldMapper extends NumberFieldMapper { } else { value = (byte) parser.shortValue(coerce.value()); if (context.includeInAll(includeInAll, this)) { - context.allEntries().addText(fieldType().names().fullName(), parser.text(), boost); + context.allEntries().addText(fieldType().name(), parser.text(), boost); } } } diff --git a/core/src/main/java/org/elasticsearch/index/mapper/core/CompletionFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/core/CompletionFieldMapper.java index f4060dee821..1e45780cf18 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/core/CompletionFieldMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/core/CompletionFieldMapper.java @@ -326,15 +326,15 @@ public class CompletionFieldMapper extends FieldMapper implements ArrayValueMapp CompletionFieldType other = (CompletionFieldType)fieldType; if (preservePositionIncrements != other.preservePositionIncrements) { - conflicts.add("mapper [" + names().fullName() + "] has different [preserve_position_increments] values"); + conflicts.add("mapper [" + name() + "] has different [preserve_position_increments] values"); } if (preserveSep != other.preserveSep) { - conflicts.add("mapper [" + names().fullName() + "] has different [preserve_separators] values"); + conflicts.add("mapper [" + name() + "] has different [preserve_separators] values"); } if (hasContextMappings() != other.hasContextMappings()) { - conflicts.add("mapper [" + names().fullName() + "] has different [context_mappings] values"); + conflicts.add("mapper [" + name() + "] has different [context_mappings] values"); } else if (hasContextMappings() && contextMappings.equals(other.contextMappings) == false) { - conflicts.add("mapper [" + names().fullName() + "] has different [context_mappings] values"); + conflicts.add("mapper [" + name() + "] has different [context_mappings] values"); } } @@ -446,7 +446,7 @@ public class CompletionFieldMapper extends FieldMapper implements ArrayValueMapp Token token = parser.currentToken(); Map inputMap = new HashMap<>(1); if (token == Token.VALUE_NULL) { - throw new MapperParsingException("completion field [" + fieldType().names().fullName() + "] does not support null values"); + throw new MapperParsingException("completion field [" + fieldType().name() + "] does not support null values"); } else if (token == Token.START_ARRAY) { while ((token = parser.nextToken()) != Token.END_ARRAY) { parse(context, token, parser, inputMap); @@ -469,10 +469,10 @@ public class CompletionFieldMapper extends FieldMapper implements ArrayValueMapp } CompletionInputMetaData metaData = completionInput.getValue(); if (fieldType().hasContextMappings()) { - fieldType().getContextMappings().addField(context.doc(), fieldType().names().indexName(), + fieldType().getContextMappings().addField(context.doc(), fieldType().name(), input, metaData.weight, metaData.contexts); } else { - context.doc().add(new SuggestField(fieldType().names().indexName(), input, metaData.weight)); + context.doc().add(new SuggestField(fieldType().name(), input, metaData.weight)); } } multiFields.parse(this, context); @@ -536,7 +536,7 @@ public class CompletionFieldMapper extends FieldMapper implements ArrayValueMapp weight = weightValue.intValue(); } else if (Fields.CONTENT_FIELD_NAME_CONTEXTS.equals(currentFieldName)) { if (fieldType().hasContextMappings() == false) { - throw new IllegalArgumentException("contexts field is not supported for field: [" + fieldType().names().fullName() + "]"); + throw new IllegalArgumentException("contexts field is not supported for field: [" + fieldType().name() + "]"); } ContextMappings contextMappings = fieldType().getContextMappings(); XContentParser.Token currentToken = parser.currentToken(); diff --git a/core/src/main/java/org/elasticsearch/index/mapper/core/DateFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/core/DateFieldMapper.java index 7a99e6b50c0..1bd018f3f6b 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/core/DateFieldMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/core/DateFieldMapper.java @@ -249,7 +249,7 @@ public class DateFieldMapper extends NumberFieldMapper { @Override public String toString(String s) { final StringBuilder sb = new StringBuilder(); - return sb.append(names().indexName()).append(':') + return sb.append(name()).append(':') .append(includeLower ? '[' : '{') .append((lowerTerm == null) ? "*" : lowerTerm.toString()) .append(" TO ") @@ -306,13 +306,13 @@ public class DateFieldMapper extends NumberFieldMapper { if (strict) { DateFieldType other = (DateFieldType)fieldType; if (Objects.equals(dateTimeFormatter().format(), other.dateTimeFormatter().format()) == false) { - conflicts.add("mapper [" + names().fullName() + "] is used by multiple types. Set update_all_types to true to update [format] across all types."); + conflicts.add("mapper [" + name() + "] is used by multiple types. Set update_all_types to true to update [format] across all types."); } if (Objects.equals(dateTimeFormatter().locale(), other.dateTimeFormatter().locale()) == false) { - conflicts.add("mapper [" + names().fullName() + "] is used by multiple types. Set update_all_types to true to update [locale] across all types."); + conflicts.add("mapper [" + name() + "] is used by multiple types. Set update_all_types to true to update [locale] across all types."); } if (Objects.equals(timeUnit(), other.timeUnit()) == false) { - conflicts.add("mapper [" + names().fullName() + "] is used by multiple types. Set update_all_types to true to update [numeric_resolution] across all types."); + conflicts.add("mapper [" + name() + "] is used by multiple types. Set update_all_types to true to update [numeric_resolution] across all types."); } } } @@ -404,7 +404,7 @@ public class DateFieldMapper extends NumberFieldMapper { // not a time format iSim = fuzziness.asLong(); } - return NumericRangeQuery.newLongRange(names().indexName(), numericPrecisionStep(), + return NumericRangeQuery.newLongRange(name(), numericPrecisionStep(), iValue - iSim, iValue + iSim, true, true); @@ -424,7 +424,7 @@ public class DateFieldMapper extends NumberFieldMapper { } private Query innerRangeQuery(Object lowerTerm, Object upperTerm, boolean includeLower, boolean includeUpper, @Nullable DateTimeZone timeZone, @Nullable DateMathParser forcedDateParser) { - return NumericRangeQuery.newLongRange(names().indexName(), numericPrecisionStep(), + return NumericRangeQuery.newLongRange(name(), numericPrecisionStep(), lowerTerm == null ? null : parseToMilliseconds(lowerTerm, !includeLower, timeZone, forcedDateParser == null ? dateMathParser : forcedDateParser), upperTerm == null ? null : parseToMilliseconds(upperTerm, includeUpper, timeZone, forcedDateParser == null ? dateMathParser : forcedDateParser), includeLower, includeUpper); @@ -516,7 +516,7 @@ public class DateFieldMapper extends NumberFieldMapper { Long value = null; if (dateAsString != null) { if (context.includeInAll(includeInAll, this)) { - context.allEntries().addText(fieldType().names().fullName(), dateAsString, boost); + context.allEntries().addText(fieldType().name(), dateAsString, boost); } value = fieldType().parseStringValue(dateAsString); } diff --git a/core/src/main/java/org/elasticsearch/index/mapper/core/DoubleFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/core/DoubleFieldMapper.java index 861d33e560e..18fd27883cd 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/core/DoubleFieldMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/core/DoubleFieldMapper.java @@ -164,7 +164,7 @@ public class DoubleFieldMapper extends NumberFieldMapper { @Override public Query rangeQuery(Object lowerTerm, Object upperTerm, boolean includeLower, boolean includeUpper) { - return NumericRangeQuery.newDoubleRange(names().indexName(), numericPrecisionStep(), + return NumericRangeQuery.newDoubleRange(name(), numericPrecisionStep(), lowerTerm == null ? null : parseDoubleValue(lowerTerm), upperTerm == null ? null : parseDoubleValue(upperTerm), includeLower, includeUpper); @@ -174,7 +174,7 @@ public class DoubleFieldMapper extends NumberFieldMapper { public Query fuzzyQuery(Object value, Fuzziness fuzziness, int prefixLength, int maxExpansions, boolean transpositions) { double iValue = parseDoubleValue(value); double iSim = fuzziness.asDouble(); - return NumericRangeQuery.newDoubleRange(names().indexName(), numericPrecisionStep(), + return NumericRangeQuery.newDoubleRange(name(), numericPrecisionStep(), iValue - iSim, iValue + iSim, true, true); @@ -230,7 +230,7 @@ public class DoubleFieldMapper extends NumberFieldMapper { value = ((Number) externalValue).doubleValue(); } if (context.includeInAll(includeInAll, this)) { - context.allEntries().addText(fieldType().names().fullName(), Double.toString(value), boost); + context.allEntries().addText(fieldType().name(), Double.toString(value), boost); } } else { XContentParser parser = context.parser(); @@ -241,7 +241,7 @@ public class DoubleFieldMapper extends NumberFieldMapper { } value = fieldType().nullValue(); if (fieldType().nullValueAsString() != null && (context.includeInAll(includeInAll, this))) { - context.allEntries().addText(fieldType().names().fullName(), fieldType().nullValueAsString(), boost); + context.allEntries().addText(fieldType().name(), fieldType().nullValueAsString(), boost); } } else if (parser.currentToken() == XContentParser.Token.START_OBJECT) { XContentParser.Token token; @@ -270,7 +270,7 @@ public class DoubleFieldMapper extends NumberFieldMapper { } else { value = parser.doubleValue(coerce.value()); if (context.includeInAll(includeInAll, this)) { - context.allEntries().addText(fieldType().names().fullName(), parser.text(), boost); + context.allEntries().addText(fieldType().name(), parser.text(), boost); } } } diff --git a/core/src/main/java/org/elasticsearch/index/mapper/core/FloatFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/core/FloatFieldMapper.java index ad88c745dfd..4f8477b5f90 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/core/FloatFieldMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/core/FloatFieldMapper.java @@ -165,7 +165,7 @@ public class FloatFieldMapper extends NumberFieldMapper { @Override public Query rangeQuery(Object lowerTerm, Object upperTerm, boolean includeLower, boolean includeUpper) { - return NumericRangeQuery.newFloatRange(names().indexName(), numericPrecisionStep(), + return NumericRangeQuery.newFloatRange(name(), numericPrecisionStep(), lowerTerm == null ? null : parseValue(lowerTerm), upperTerm == null ? null : parseValue(upperTerm), includeLower, includeUpper); @@ -175,7 +175,7 @@ public class FloatFieldMapper extends NumberFieldMapper { public Query fuzzyQuery(Object value, Fuzziness fuzziness, int prefixLength, int maxExpansions, boolean transpositions) { float iValue = parseValue(value); final float iSim = fuzziness.asFloat(); - return NumericRangeQuery.newFloatRange(names().indexName(), numericPrecisionStep(), + return NumericRangeQuery.newFloatRange(name(), numericPrecisionStep(), iValue - iSim, iValue + iSim, true, true); @@ -242,7 +242,7 @@ public class FloatFieldMapper extends NumberFieldMapper { value = ((Number) externalValue).floatValue(); } if (context.includeInAll(includeInAll, this)) { - context.allEntries().addText(fieldType().names().fullName(), Float.toString(value), boost); + context.allEntries().addText(fieldType().name(), Float.toString(value), boost); } } else { XContentParser parser = context.parser(); @@ -253,7 +253,7 @@ public class FloatFieldMapper extends NumberFieldMapper { } value = fieldType().nullValue(); if (fieldType().nullValueAsString() != null && (context.includeInAll(includeInAll, this))) { - context.allEntries().addText(fieldType().names().fullName(), fieldType().nullValueAsString(), boost); + context.allEntries().addText(fieldType().name(), fieldType().nullValueAsString(), boost); } } else if (parser.currentToken() == XContentParser.Token.START_OBJECT) { XContentParser.Token token; @@ -282,7 +282,7 @@ public class FloatFieldMapper extends NumberFieldMapper { } else { value = parser.floatValue(coerce.value()); if (context.includeInAll(includeInAll, this)) { - context.allEntries().addText(fieldType().names().fullName(), parser.text(), boost); + context.allEntries().addText(fieldType().name(), parser.text(), boost); } } } diff --git a/core/src/main/java/org/elasticsearch/index/mapper/core/IntegerFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/core/IntegerFieldMapper.java index 67f6a5e21b3..5fda6045928 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/core/IntegerFieldMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/core/IntegerFieldMapper.java @@ -170,7 +170,7 @@ public class IntegerFieldMapper extends NumberFieldMapper { @Override public Query rangeQuery(Object lowerTerm, Object upperTerm, boolean includeLower, boolean includeUpper) { - return NumericRangeQuery.newIntRange(names().indexName(), numericPrecisionStep(), + return NumericRangeQuery.newIntRange(name(), numericPrecisionStep(), lowerTerm == null ? null : parseValue(lowerTerm), upperTerm == null ? null : parseValue(upperTerm), includeLower, includeUpper); @@ -180,7 +180,7 @@ public class IntegerFieldMapper extends NumberFieldMapper { public Query fuzzyQuery(Object value, Fuzziness fuzziness, int prefixLength, int maxExpansions, boolean transpositions) { int iValue = parseValue(value); int iSim = fuzziness.asInt(); - return NumericRangeQuery.newIntRange(names().indexName(), numericPrecisionStep(), + return NumericRangeQuery.newIntRange(name(), numericPrecisionStep(), iValue - iSim, iValue + iSim, true, true); @@ -247,7 +247,7 @@ public class IntegerFieldMapper extends NumberFieldMapper { value = ((Number) externalValue).intValue(); } if (context.includeInAll(includeInAll, this)) { - context.allEntries().addText(fieldType().names().fullName(), Integer.toString(value), boost); + context.allEntries().addText(fieldType().name(), Integer.toString(value), boost); } } else { XContentParser parser = context.parser(); @@ -258,7 +258,7 @@ public class IntegerFieldMapper extends NumberFieldMapper { } value = fieldType().nullValue(); if (fieldType().nullValueAsString() != null && (context.includeInAll(includeInAll, this))) { - context.allEntries().addText(fieldType().names().fullName(), fieldType().nullValueAsString(), boost); + context.allEntries().addText(fieldType().name(), fieldType().nullValueAsString(), boost); } } else if (parser.currentToken() == XContentParser.Token.START_OBJECT) { XContentParser.Token token; @@ -287,7 +287,7 @@ public class IntegerFieldMapper extends NumberFieldMapper { } else { value = parser.intValue(coerce.value()); if (context.includeInAll(includeInAll, this)) { - context.allEntries().addText(fieldType().names().fullName(), parser.text(), boost); + context.allEntries().addText(fieldType().name(), parser.text(), boost); } } } diff --git a/core/src/main/java/org/elasticsearch/index/mapper/core/LongFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/core/LongFieldMapper.java index a19079c3db9..02cfa7f81e7 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/core/LongFieldMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/core/LongFieldMapper.java @@ -168,7 +168,7 @@ public class LongFieldMapper extends NumberFieldMapper { @Override public Query rangeQuery(Object lowerTerm, Object upperTerm, boolean includeLower, boolean includeUpper) { - return NumericRangeQuery.newLongRange(names().indexName(), numericPrecisionStep(), + return NumericRangeQuery.newLongRange(name(), numericPrecisionStep(), lowerTerm == null ? null : parseLongValue(lowerTerm), upperTerm == null ? null : parseLongValue(upperTerm), includeLower, includeUpper); @@ -178,7 +178,7 @@ public class LongFieldMapper extends NumberFieldMapper { public Query fuzzyQuery(Object value, Fuzziness fuzziness, int prefixLength, int maxExpansions, boolean transpositions) { long iValue = parseLongValue(value); final long iSim = fuzziness.asLong(); - return NumericRangeQuery.newLongRange(names().indexName(), numericPrecisionStep(), + return NumericRangeQuery.newLongRange(name(), numericPrecisionStep(), iValue - iSim, iValue + iSim, true, true); @@ -235,7 +235,7 @@ public class LongFieldMapper extends NumberFieldMapper { value = ((Number) externalValue).longValue(); } if (context.includeInAll(includeInAll, this)) { - context.allEntries().addText(fieldType().names().fullName(), Long.toString(value), boost); + context.allEntries().addText(fieldType().name(), Long.toString(value), boost); } } else { XContentParser parser = context.parser(); @@ -246,7 +246,7 @@ public class LongFieldMapper extends NumberFieldMapper { } value = fieldType().nullValue(); if (fieldType().nullValueAsString() != null && (context.includeInAll(includeInAll, this))) { - context.allEntries().addText(fieldType().names().fullName(), fieldType().nullValueAsString(), boost); + context.allEntries().addText(fieldType().name(), fieldType().nullValueAsString(), boost); } } else if (parser.currentToken() == XContentParser.Token.START_OBJECT) { XContentParser.Token token; @@ -275,7 +275,7 @@ public class LongFieldMapper extends NumberFieldMapper { } else { value = parser.longValue(coerce.value()); if (context.includeInAll(includeInAll, this)) { - context.allEntries().addText(fieldType().names().fullName(), parser.text(), boost); + context.allEntries().addText(fieldType().name(), parser.text(), boost); } } } diff --git a/core/src/main/java/org/elasticsearch/index/mapper/core/NumberFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/core/NumberFieldMapper.java index 618114685ae..a0a5e5e5bce 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/core/NumberFieldMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/core/NumberFieldMapper.java @@ -144,7 +144,7 @@ public abstract class NumberFieldMapper extends FieldMapper implements AllFieldM List conflicts, boolean strict) { super.checkCompatibility(other, conflicts, strict); if (numericPrecisionStep() != other.numericPrecisionStep()) { - conflicts.add("mapper [" + names().fullName() + "] has different [precision_step] values"); + conflicts.add("mapper [" + name() + "] has different [precision_step] values"); } } @@ -243,7 +243,7 @@ public abstract class NumberFieldMapper extends FieldMapper implements AllFieldM protected abstract void innerParseCreateField(ParseContext context, List fields) throws IOException; protected final void addDocValue(ParseContext context, List fields, long value) { - fields.add(new SortedNumericDocValuesField(fieldType().names().indexName(), value)); + fields.add(new SortedNumericDocValuesField(fieldType().name(), value)); } /** @@ -329,7 +329,7 @@ public abstract class NumberFieldMapper extends FieldMapper implements AllFieldM }; public CustomNumericField(Number value, MappedFieldType fieldType) { - super(fieldType.names().indexName(), fieldType); + super(fieldType.name(), fieldType); if (value != null) { this.fieldsData = value; } diff --git a/core/src/main/java/org/elasticsearch/index/mapper/core/ShortFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/core/ShortFieldMapper.java index 017fd6493c5..7c232c46fb5 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/core/ShortFieldMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/core/ShortFieldMapper.java @@ -166,7 +166,7 @@ public class ShortFieldMapper extends NumberFieldMapper { @Override public Query rangeQuery(Object lowerTerm, Object upperTerm, boolean includeLower, boolean includeUpper) { - return NumericRangeQuery.newIntRange(names().indexName(), numericPrecisionStep(), + return NumericRangeQuery.newIntRange(name(), numericPrecisionStep(), lowerTerm == null ? null : (int)parseValue(lowerTerm), upperTerm == null ? null : (int)parseValue(upperTerm), includeLower, includeUpper); @@ -176,7 +176,7 @@ public class ShortFieldMapper extends NumberFieldMapper { public Query fuzzyQuery(Object value, Fuzziness fuzziness, int prefixLength, int maxExpansions, boolean transpositions) { short iValue = parseValue(value); short iSim = fuzziness.asShort(); - return NumericRangeQuery.newIntRange(names().indexName(), numericPrecisionStep(), + return NumericRangeQuery.newIntRange(name(), numericPrecisionStep(), iValue - iSim, iValue + iSim, true, true); @@ -243,7 +243,7 @@ public class ShortFieldMapper extends NumberFieldMapper { value = ((Number) externalValue).shortValue(); } if (context.includeInAll(includeInAll, this)) { - context.allEntries().addText(fieldType().names().fullName(), Short.toString(value), boost); + context.allEntries().addText(fieldType().name(), Short.toString(value), boost); } } else { XContentParser parser = context.parser(); @@ -254,7 +254,7 @@ public class ShortFieldMapper extends NumberFieldMapper { } value = fieldType().nullValue(); if (fieldType().nullValueAsString() != null && (context.includeInAll(includeInAll, this))) { - context.allEntries().addText(fieldType().names().fullName(), fieldType().nullValueAsString(), boost); + context.allEntries().addText(fieldType().name(), fieldType().nullValueAsString(), boost); } } else if (parser.currentToken() == XContentParser.Token.START_OBJECT) { XContentParser.Token token; @@ -283,7 +283,7 @@ public class ShortFieldMapper extends NumberFieldMapper { } else { value = parser.shortValue(coerce.value()); if (context.includeInAll(includeInAll, this)) { - context.allEntries().addText(fieldType().names().fullName(), parser.text(), boost); + context.allEntries().addText(fieldType().name(), parser.text(), boost); } } } diff --git a/core/src/main/java/org/elasticsearch/index/mapper/core/StringFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/core/StringFieldMapper.java index 0762c9a6698..f8f9cb25ba1 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/core/StringFieldMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/core/StringFieldMapper.java @@ -248,7 +248,7 @@ public class StringFieldMapper extends FieldMapper implements AllFieldMapper.Inc Settings indexSettings, MultiFields multiFields, CopyTo copyTo) { super(simpleName, fieldType, defaultFieldType, indexSettings, multiFields, copyTo); if (fieldType.tokenized() && fieldType.indexOptions() != NONE && fieldType().hasDocValues()) { - throw new MapperParsingException("Field [" + fieldType.names().fullName() + "] cannot be analyzed and have doc values"); + throw new MapperParsingException("Field [" + fieldType.name() + "] cannot be analyzed and have doc values"); } this.positionIncrementGap = positionIncrementGap; this.ignoreAbove = ignoreAbove; @@ -315,19 +315,19 @@ public class StringFieldMapper extends FieldMapper implements AllFieldMapper.Inc return; } if (context.includeInAll(includeInAll, this)) { - context.allEntries().addText(fieldType().names().fullName(), valueAndBoost.value(), valueAndBoost.boost()); + context.allEntries().addText(fieldType().name(), valueAndBoost.value(), valueAndBoost.boost()); } if (fieldType().indexOptions() != IndexOptions.NONE || fieldType().stored()) { - Field field = new Field(fieldType().names().indexName(), valueAndBoost.value(), fieldType()); + Field field = new Field(fieldType().name(), valueAndBoost.value(), fieldType()); field.setBoost(valueAndBoost.boost()); fields.add(field); } if (fieldType().hasDocValues()) { - fields.add(new SortedSetDocValuesField(fieldType().names().indexName(), new BytesRef(valueAndBoost.value()))); + fields.add(new SortedSetDocValuesField(fieldType().name(), new BytesRef(valueAndBoost.value()))); } if (fields.isEmpty()) { - context.ignoredValue(fieldType().names().indexName(), valueAndBoost.value()); + context.ignoredValue(fieldType().name(), valueAndBoost.value()); } } diff --git a/core/src/main/java/org/elasticsearch/index/mapper/core/TokenCountFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/core/TokenCountFieldMapper.java index a485c3727fc..1fd1debe60c 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/core/TokenCountFieldMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/core/TokenCountFieldMapper.java @@ -148,7 +148,7 @@ public class TokenCountFieldMapper extends IntegerFieldMapper { addIntegerFields(context, fields, count, valueAndBoost.boost()); } if (fields.isEmpty()) { - context.ignoredValue(fieldType().names().indexName(), valueAndBoost.value()); + context.ignoredValue(fieldType().name(), valueAndBoost.value()); } } diff --git a/core/src/main/java/org/elasticsearch/index/mapper/core/TypeParsers.java b/core/src/main/java/org/elasticsearch/index/mapper/core/TypeParsers.java index 00d39791c9c..3ebba17d65c 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/core/TypeParsers.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/core/TypeParsers.java @@ -241,10 +241,7 @@ public class TypeParsers { Map.Entry entry = iterator.next(); final String propName = Strings.toUnderscoreCase(entry.getKey()); final Object propNode = entry.getValue(); - if (propName.equals("index_name") && indexVersionCreated.before(Version.V_2_0_0_beta1)) { - builder.indexName(propNode.toString()); - iterator.remove(); - } else if (propName.equals("store")) { + if (propName.equals("store")) { builder.store(parseStore(name, propNode.toString())); iterator.remove(); } else if (propName.equals("index")) { diff --git a/core/src/main/java/org/elasticsearch/index/mapper/geo/BaseGeoPointFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/geo/BaseGeoPointFieldMapper.java index 79261ec3809..11683ee9a8d 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/geo/BaseGeoPointFieldMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/geo/BaseGeoPointFieldMapper.java @@ -287,20 +287,20 @@ public abstract class BaseGeoPointFieldMapper extends FieldMapper implements Arr super.checkCompatibility(fieldType, conflicts, strict); GeoPointFieldType other = (GeoPointFieldType)fieldType; if (isLatLonEnabled() != other.isLatLonEnabled()) { - conflicts.add("mapper [" + names().fullName() + "] has different [lat_lon]"); + conflicts.add("mapper [" + name() + "] has different [lat_lon]"); } if (isLatLonEnabled() && other.isLatLonEnabled() && latFieldType().numericPrecisionStep() != other.latFieldType().numericPrecisionStep()) { - conflicts.add("mapper [" + names().fullName() + "] has different [precision_step]"); + conflicts.add("mapper [" + name() + "] has different [precision_step]"); } if (isGeoHashEnabled() != other.isGeoHashEnabled()) { - conflicts.add("mapper [" + names().fullName() + "] has different [geohash]"); + conflicts.add("mapper [" + name() + "] has different [geohash]"); } if (geoHashPrecision() != other.geoHashPrecision()) { - conflicts.add("mapper [" + names().fullName() + "] has different [geohash_precision]"); + conflicts.add("mapper [" + name() + "] has different [geohash_precision]"); } if (isGeoHashPrefixEnabled() != other.isGeoHashPrefixEnabled()) { - conflicts.add("mapper [" + names().fullName() + "] has different [geohash_prefix]"); + conflicts.add("mapper [" + name() + "] has different [geohash_prefix]"); } } diff --git a/core/src/main/java/org/elasticsearch/index/mapper/geo/GeoPointFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/geo/GeoPointFieldMapper.java index fa61669e800..450c987ae54 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/geo/GeoPointFieldMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/geo/GeoPointFieldMapper.java @@ -123,7 +123,7 @@ public class GeoPointFieldMapper extends BaseGeoPointFieldMapper { GeoUtils.normalizePoint(point); } if (fieldType().indexOptions() != IndexOptions.NONE || fieldType().stored()) { - context.doc().add(new GeoPointField(fieldType().names().indexName(), point.lon(), point.lat(), fieldType() )); + context.doc().add(new GeoPointField(fieldType().name(), point.lon(), point.lat(), fieldType() )); } super.parse(context, point, geoHash); } diff --git a/core/src/main/java/org/elasticsearch/index/mapper/geo/GeoPointFieldMapperLegacy.java b/core/src/main/java/org/elasticsearch/index/mapper/geo/GeoPointFieldMapperLegacy.java index 735baa88533..589abd99191 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/geo/GeoPointFieldMapperLegacy.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/geo/GeoPointFieldMapperLegacy.java @@ -301,7 +301,7 @@ public class GeoPointFieldMapperLegacy extends BaseGeoPointFieldMapper implement GeoPointFieldMapperLegacy gpfmMergeWith = (GeoPointFieldMapperLegacy) mergeWith; if (gpfmMergeWith.coerce.explicit()) { if (coerce.explicit() && coerce.value() != gpfmMergeWith.coerce.value()) { - throw new IllegalArgumentException("mapper [" + fieldType().names().fullName() + "] has different [coerce]"); + throw new IllegalArgumentException("mapper [" + fieldType().name() + "] has different [coerce]"); } } @@ -330,17 +330,17 @@ public class GeoPointFieldMapperLegacy extends BaseGeoPointFieldMapper implement } if (fieldType().indexOptions() != IndexOptions.NONE || fieldType().stored()) { - Field field = new Field(fieldType().names().indexName(), Double.toString(point.lat()) + ',' + Double.toString(point.lon()), fieldType()); + Field field = new Field(fieldType().name(), Double.toString(point.lat()) + ',' + Double.toString(point.lon()), fieldType()); context.doc().add(field); } super.parse(context, point, geoHash); if (fieldType().hasDocValues()) { - CustomGeoPointDocValuesField field = (CustomGeoPointDocValuesField) context.doc().getByKey(fieldType().names().indexName()); + CustomGeoPointDocValuesField field = (CustomGeoPointDocValuesField) context.doc().getByKey(fieldType().name()); if (field == null) { - field = new CustomGeoPointDocValuesField(fieldType().names().indexName(), point.lat(), point.lon()); - context.doc().addWithKey(fieldType().names().indexName(), field); + field = new CustomGeoPointDocValuesField(fieldType().name(), point.lat(), point.lon()); + context.doc().addWithKey(fieldType().name(), field); } else { field.add(point.lat(), point.lon()); } diff --git a/core/src/main/java/org/elasticsearch/index/mapper/geo/GeoShapeFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/geo/GeoShapeFieldMapper.java index 1ba49e64d80..9cb38e38a62 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/geo/GeoShapeFieldMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/geo/GeoShapeFieldMapper.java @@ -105,7 +105,7 @@ public class GeoShapeFieldMapper extends FieldMapper { static { // setting name here is a hack so freeze can be called...instead all these options should be // moved to the default ctor for GeoShapeFieldType, and defaultFieldType() should be removed from mappers... - FIELD_TYPE.setNames(new MappedFieldType.Names("DoesNotExist")); + FIELD_TYPE.setName("DoesNotExist"); FIELD_TYPE.setIndexOptions(IndexOptions.DOCS); FIELD_TYPE.setTokenized(false); FIELD_TYPE.setStored(false); @@ -278,10 +278,10 @@ public class GeoShapeFieldMapper extends FieldMapper { throw new IllegalArgumentException("Unknown prefix tree type [" + tree + "]"); } - recursiveStrategy = new RecursivePrefixTreeStrategy(prefixTree, names().indexName()); + recursiveStrategy = new RecursivePrefixTreeStrategy(prefixTree, name()); recursiveStrategy.setDistErrPct(distanceErrorPct()); recursiveStrategy.setPruneLeafyBranches(false); - termStrategy = new TermQueryPrefixTreeStrategy(prefixTree, names().indexName()); + termStrategy = new TermQueryPrefixTreeStrategy(prefixTree, name()); termStrategy.setDistErrPct(distanceErrorPct()); defaultStrategy = resolveStrategy(strategyName); defaultStrategy.setPointsOnly(pointsOnly); @@ -293,33 +293,33 @@ public class GeoShapeFieldMapper extends FieldMapper { GeoShapeFieldType other = (GeoShapeFieldType)fieldType; // prevent user from changing strategies if (strategyName().equals(other.strategyName()) == false) { - conflicts.add("mapper [" + names().fullName() + "] has different [strategy]"); + conflicts.add("mapper [" + name() + "] has different [strategy]"); } // prevent user from changing trees (changes encoding) if (tree().equals(other.tree()) == false) { - conflicts.add("mapper [" + names().fullName() + "] has different [tree]"); + conflicts.add("mapper [" + name() + "] has different [tree]"); } if ((pointsOnly() != other.pointsOnly())) { - conflicts.add("mapper [" + names().fullName() + "] has different points_only"); + conflicts.add("mapper [" + name() + "] has different points_only"); } // TODO we should allow this, but at the moment levels is used to build bookkeeping variables // in lucene's SpatialPrefixTree implementations, need a patch to correct that first if (treeLevels() != other.treeLevels()) { - conflicts.add("mapper [" + names().fullName() + "] has different [tree_levels]"); + conflicts.add("mapper [" + name() + "] has different [tree_levels]"); } if (precisionInMeters() != other.precisionInMeters()) { - conflicts.add("mapper [" + names().fullName() + "] has different [precision]"); + conflicts.add("mapper [" + name() + "] has different [precision]"); } if (strict) { if (orientation() != other.orientation()) { - conflicts.add("mapper [" + names().fullName() + "] is used by multiple types. Set update_all_types to true to update [orientation] across all types."); + conflicts.add("mapper [" + name() + "] is used by multiple types. Set update_all_types to true to update [orientation] across all types."); } if (distanceErrorPct() != other.distanceErrorPct()) { - conflicts.add("mapper [" + names().fullName() + "] is used by multiple types. Set update_all_types to true to update [distance_error_pct] across all types."); + conflicts.add("mapper [" + name() + "] is used by multiple types. Set update_all_types to true to update [distance_error_pct] across all types."); } } } @@ -450,7 +450,7 @@ public class GeoShapeFieldMapper extends FieldMapper { shape = shapeBuilder.build(); } if (fieldType().pointsOnly() && !(shape instanceof Point)) { - throw new MapperParsingException("[{" + fieldType().names().fullName() + "}] is configured for points only but a " + + throw new MapperParsingException("[{" + fieldType().name() + "}] is configured for points only but a " + ((shape instanceof JtsGeometry) ? ((JtsGeometry)shape).getGeom().getGeometryType() : shape.getClass()) + " was found"); } Field[] fields = fieldType().defaultStrategy().createIndexableFields(shape); @@ -464,7 +464,7 @@ public class GeoShapeFieldMapper extends FieldMapper { context.doc().add(field); } } catch (Exception e) { - throw new MapperParsingException("failed to parse [" + fieldType().names().fullName() + "]", e); + throw new MapperParsingException("failed to parse [" + fieldType().name() + "]", e); } return null; } diff --git a/core/src/main/java/org/elasticsearch/index/mapper/internal/AllFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/internal/AllFieldMapper.java index bcd094d2ae6..d370cbe9645 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/internal/AllFieldMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/internal/AllFieldMapper.java @@ -91,7 +91,7 @@ public class AllFieldMapper extends MetadataFieldMapper { static { FIELD_TYPE.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS); FIELD_TYPE.setTokenized(true); - FIELD_TYPE.setNames(new MappedFieldType.Names(NAME)); + FIELD_TYPE.setName(NAME); FIELD_TYPE.freeze(); } } @@ -246,7 +246,7 @@ public class AllFieldMapper extends MetadataFieldMapper { // reset the entries context.allEntries().reset(); Analyzer analyzer = findAnalyzer(context); - fields.add(new AllField(fieldType().names().indexName(), context.allEntries(), analyzer, fieldType())); + fields.add(new AllField(fieldType().name(), context.allEntries(), analyzer, fieldType())); } private Analyzer findAnalyzer(ParseContext context) { @@ -323,7 +323,7 @@ public class AllFieldMapper extends MetadataFieldMapper { @Override protected void doMerge(Mapper mergeWith, boolean updateAllTypes) { if (((AllFieldMapper)mergeWith).enabled() != this.enabled() && ((AllFieldMapper)mergeWith).enabledState != Defaults.ENABLED) { - throw new IllegalArgumentException("mapper [" + fieldType().names().fullName() + "] enabled is " + this.enabled() + " now encountering "+ ((AllFieldMapper)mergeWith).enabled()); + throw new IllegalArgumentException("mapper [" + fieldType().name() + "] enabled is " + this.enabled() + " now encountering "+ ((AllFieldMapper)mergeWith).enabled()); } super.doMerge(mergeWith, updateAllTypes); } diff --git a/core/src/main/java/org/elasticsearch/index/mapper/internal/FieldNamesFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/internal/FieldNamesFieldMapper.java index d8d61f4bab3..cd4fdc533e4 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/internal/FieldNamesFieldMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/internal/FieldNamesFieldMapper.java @@ -69,7 +69,7 @@ public class FieldNamesFieldMapper extends MetadataFieldMapper { FIELD_TYPE.setOmitNorms(true); FIELD_TYPE.setIndexAnalyzer(Lucene.KEYWORD_ANALYZER); FIELD_TYPE.setSearchAnalyzer(Lucene.KEYWORD_ANALYZER); - FIELD_TYPE.setNames(new MappedFieldType.Names(NAME)); + FIELD_TYPE.setName(NAME); FIELD_TYPE.freeze(); } } @@ -175,7 +175,7 @@ public class FieldNamesFieldMapper extends MetadataFieldMapper { if (strict) { FieldNamesFieldType other = (FieldNamesFieldType)fieldType; if (isEnabled() != other.isEnabled()) { - conflicts.add("mapper [" + names().fullName() + "] is used by multiple types. Set update_all_types to true to update [enabled] across all types."); + conflicts.add("mapper [" + name() + "] is used by multiple types. Set update_all_types to true to update [enabled] across all types."); } } } @@ -290,7 +290,7 @@ public class FieldNamesFieldMapper extends MetadataFieldMapper { for (String path : paths) { for (String fieldName : extractFieldNames(path)) { if (fieldType().indexOptions() != IndexOptions.NONE || fieldType().stored()) { - document.add(new Field(fieldType().names().indexName(), fieldName, fieldType())); + document.add(new Field(fieldType().name(), fieldName, fieldType())); } } } diff --git a/core/src/main/java/org/elasticsearch/index/mapper/internal/IdFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/internal/IdFieldMapper.java index 0fe3e10bcb8..a342f5b2180 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/internal/IdFieldMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/internal/IdFieldMapper.java @@ -77,7 +77,7 @@ public class IdFieldMapper extends MetadataFieldMapper { FIELD_TYPE.setOmitNorms(true); FIELD_TYPE.setIndexAnalyzer(Lucene.KEYWORD_ANALYZER); FIELD_TYPE.setSearchAnalyzer(Lucene.KEYWORD_ANALYZER); - FIELD_TYPE.setNames(new MappedFieldType.Names(NAME)); + FIELD_TYPE.setName(NAME); FIELD_TYPE.freeze(); } @@ -285,10 +285,10 @@ public class IdFieldMapper extends MetadataFieldMapper { } // else we are in the pre/post parse phase if (fieldType().indexOptions() != IndexOptions.NONE || fieldType().stored()) { - fields.add(new Field(fieldType().names().indexName(), context.id(), fieldType())); + fields.add(new Field(fieldType().name(), context.id(), fieldType())); } if (fieldType().hasDocValues()) { - fields.add(new BinaryDocValuesField(fieldType().names().indexName(), new BytesRef(context.id()))); + fields.add(new BinaryDocValuesField(fieldType().name(), new BytesRef(context.id()))); } } diff --git a/core/src/main/java/org/elasticsearch/index/mapper/internal/IndexFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/internal/IndexFieldMapper.java index dbbf03b72e2..52a2e97508c 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/internal/IndexFieldMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/internal/IndexFieldMapper.java @@ -67,7 +67,7 @@ public class IndexFieldMapper extends MetadataFieldMapper { FIELD_TYPE.setOmitNorms(true); FIELD_TYPE.setIndexAnalyzer(Lucene.KEYWORD_ANALYZER); FIELD_TYPE.setSearchAnalyzer(Lucene.KEYWORD_ANALYZER); - FIELD_TYPE.setNames(new MappedFieldType.Names(NAME)); + FIELD_TYPE.setName(NAME); FIELD_TYPE.freeze(); } @@ -223,7 +223,7 @@ public class IndexFieldMapper extends MetadataFieldMapper { } public String value(Document document) { - Field field = (Field) document.getField(fieldType().names().indexName()); + Field field = (Field) document.getField(fieldType().name()); return field == null ? null : (String)fieldType().value(field); } @@ -247,7 +247,7 @@ public class IndexFieldMapper extends MetadataFieldMapper { if (!enabledState.enabled) { return; } - fields.add(new Field(fieldType().names().indexName(), context.index(), fieldType())); + fields.add(new Field(fieldType().name(), context.index(), fieldType())); } @Override diff --git a/core/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java index 65daef2a834..4325dfc8a96 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/internal/ParentFieldMapper.java @@ -75,7 +75,7 @@ public class ParentFieldMapper extends MetadataFieldMapper { FIELD_TYPE.setOmitNorms(true); FIELD_TYPE.setIndexAnalyzer(Lucene.KEYWORD_ANALYZER); FIELD_TYPE.setSearchAnalyzer(Lucene.KEYWORD_ANALYZER); - FIELD_TYPE.setNames(new MappedFieldType.Names(NAME)); + FIELD_TYPE.setName(NAME); FIELD_TYPE.freeze(); JOIN_FIELD_TYPE.setHasDocValues(true); @@ -120,9 +120,9 @@ public class ParentFieldMapper extends MetadataFieldMapper { if (parentType == null) { throw new MapperParsingException("[_parent] field mapping must contain the [type] option"); } - parentJoinFieldType.setNames(new MappedFieldType.Names(joinField(documentType))); + parentJoinFieldType.setName(joinField(documentType)); parentJoinFieldType.setFieldDataType(null); - childJoinFieldType.setNames(new MappedFieldType.Names(joinField(parentType))); + childJoinFieldType.setName(joinField(parentType)); return new ParentFieldMapper(fieldType, parentJoinFieldType, childJoinFieldType, parentType, context.indexSettings()); } } @@ -242,7 +242,7 @@ public class ParentFieldMapper extends MetadataFieldMapper { } } } - return new TermsQuery(names().indexName(), bValues); + return new TermsQuery(name(), bValues); } } @@ -269,7 +269,7 @@ public class ParentFieldMapper extends MetadataFieldMapper { private static MappedFieldType joinFieldTypeForParentType(String parentType, Settings indexSettings) { MappedFieldType parentJoinFieldType = Defaults.JOIN_FIELD_TYPE.clone(); - parentJoinFieldType.setNames(new MappedFieldType.Names(joinField(parentType))); + parentJoinFieldType.setName(joinField(parentType)); parentJoinFieldType.freeze(); return parentJoinFieldType; } @@ -312,7 +312,7 @@ public class ParentFieldMapper extends MetadataFieldMapper { // we are in the parsing of _parent phase String parentId = context.parser().text(); context.sourceToParse().parent(parentId); - fields.add(new Field(fieldType().names().indexName(), Uid.createUid(context.stringBuilder(), parentType, parentId), fieldType())); + fields.add(new Field(fieldType().name(), Uid.createUid(context.stringBuilder(), parentType, parentId), fieldType())); addJoinFieldIfNeeded(fields, childJoinFieldType, parentId); } else { // otherwise, we are running it post processing of the xcontent @@ -324,7 +324,7 @@ public class ParentFieldMapper extends MetadataFieldMapper { throw new MapperParsingException("No parent id provided, not within the document, and not externally"); } // we did not add it in the parsing phase, add it now - fields.add(new Field(fieldType().names().indexName(), Uid.createUid(context.stringBuilder(), parentType, parentId), fieldType())); + fields.add(new Field(fieldType().name(), Uid.createUid(context.stringBuilder(), parentType, parentId), fieldType())); addJoinFieldIfNeeded(fields, childJoinFieldType, parentId); } else if (parentId != null && !parsedParentId.equals(Uid.createUid(context.stringBuilder(), parentType, parentId))) { throw new MapperParsingException("Parent id mismatch, document value is [" + Uid.createUid(parsedParentId).id() + "], while external value is [" + parentId + "]"); @@ -336,7 +336,7 @@ public class ParentFieldMapper extends MetadataFieldMapper { private void addJoinFieldIfNeeded(List fields, MappedFieldType fieldType, String id) { if (fieldType.hasDocValues()) { - fields.add(new SortedDocValuesField(fieldType.names().indexName(), new BytesRef(id))); + fields.add(new SortedDocValuesField(fieldType.name(), new BytesRef(id))); } } diff --git a/core/src/main/java/org/elasticsearch/index/mapper/internal/RoutingFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/internal/RoutingFieldMapper.java index 40b7e6871c4..4fb410dbdc8 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/internal/RoutingFieldMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/internal/RoutingFieldMapper.java @@ -62,7 +62,7 @@ public class RoutingFieldMapper extends MetadataFieldMapper { FIELD_TYPE.setOmitNorms(true); FIELD_TYPE.setIndexAnalyzer(Lucene.KEYWORD_ANALYZER); FIELD_TYPE.setSearchAnalyzer(Lucene.KEYWORD_ANALYZER); - FIELD_TYPE.setNames(new MappedFieldType.Names(NAME)); + FIELD_TYPE.setName(NAME); FIELD_TYPE.freeze(); } @@ -179,7 +179,7 @@ public class RoutingFieldMapper extends MetadataFieldMapper { } public String value(Document document) { - Field field = (Field) document.getField(fieldType().names().indexName()); + Field field = (Field) document.getField(fieldType().name()); return field == null ? null : (String)fieldType().value(field); } @@ -206,10 +206,10 @@ public class RoutingFieldMapper extends MetadataFieldMapper { String routing = context.sourceToParse().routing(); if (routing != null) { if (fieldType().indexOptions() == IndexOptions.NONE && !fieldType().stored()) { - context.ignoredValue(fieldType().names().indexName(), routing); + context.ignoredValue(fieldType().name(), routing); return; } - fields.add(new Field(fieldType().names().indexName(), routing, fieldType())); + fields.add(new Field(fieldType().name(), routing, fieldType())); } } } diff --git a/core/src/main/java/org/elasticsearch/index/mapper/internal/SourceFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/internal/SourceFieldMapper.java index 40bf9eb0c8e..b0de09edafb 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/internal/SourceFieldMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/internal/SourceFieldMapper.java @@ -74,7 +74,7 @@ public class SourceFieldMapper extends MetadataFieldMapper { FIELD_TYPE.setOmitNorms(true); FIELD_TYPE.setIndexAnalyzer(Lucene.KEYWORD_ANALYZER); FIELD_TYPE.setSearchAnalyzer(Lucene.KEYWORD_ANALYZER); - FIELD_TYPE.setNames(new MappedFieldType.Names(NAME)); + FIELD_TYPE.setName(NAME); FIELD_TYPE.freeze(); } @@ -272,7 +272,7 @@ public class SourceFieldMapper extends MetadataFieldMapper { if (!source.hasArray()) { source = source.toBytesArray(); } - fields.add(new StoredField(fieldType().names().indexName(), source.array(), source.arrayOffset(), source.length())); + fields.add(new StoredField(fieldType().name(), source.array(), source.arrayOffset(), source.length())); } @Override diff --git a/core/src/main/java/org/elasticsearch/index/mapper/internal/TTLFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/internal/TTLFieldMapper.java index f99ca18600a..4612b9fb85f 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/internal/TTLFieldMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/internal/TTLFieldMapper.java @@ -64,7 +64,7 @@ public class TTLFieldMapper extends MetadataFieldMapper { TTL_FIELD_TYPE.setNumericPrecisionStep(Defaults.PRECISION_STEP_64_BIT); TTL_FIELD_TYPE.setIndexAnalyzer(NumericLongAnalyzer.buildNamedAnalyzer(Defaults.PRECISION_STEP_64_BIT)); TTL_FIELD_TYPE.setSearchAnalyzer(NumericLongAnalyzer.buildNamedAnalyzer(Integer.MAX_VALUE)); - TTL_FIELD_TYPE.setNames(new MappedFieldType.Names(NAME)); + TTL_FIELD_TYPE.setName(NAME); TTL_FIELD_TYPE.freeze(); } diff --git a/core/src/main/java/org/elasticsearch/index/mapper/internal/TimestampFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/internal/TimestampFieldMapper.java index 9fdb9b586e4..3771747bf66 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/internal/TimestampFieldMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/internal/TimestampFieldMapper.java @@ -67,7 +67,7 @@ public class TimestampFieldMapper extends MetadataFieldMapper { FIELD_TYPE.setStored(true); FIELD_TYPE.setTokenized(false); FIELD_TYPE.setNumericPrecisionStep(Defaults.PRECISION_STEP_64_BIT); - FIELD_TYPE.setNames(new MappedFieldType.Names(NAME)); + FIELD_TYPE.setName(NAME); FIELD_TYPE.setDateTimeFormatter(DATE_TIME_FORMATTER); FIELD_TYPE.setIndexAnalyzer(NumericDateAnalyzer.buildNamedAnalyzer(DATE_TIME_FORMATTER, Defaults.PRECISION_STEP_64_BIT)); FIELD_TYPE.setSearchAnalyzer(NumericDateAnalyzer.buildNamedAnalyzer(DATE_TIME_FORMATTER, Integer.MAX_VALUE)); @@ -313,13 +313,13 @@ public class TimestampFieldMapper extends MetadataFieldMapper { if (enabledState.enabled) { long timestamp = context.sourceToParse().timestamp(); if (fieldType().indexOptions() == IndexOptions.NONE && !fieldType().stored() && !fieldType().hasDocValues()) { - context.ignoredValue(fieldType().names().indexName(), String.valueOf(timestamp)); + context.ignoredValue(fieldType().name(), String.valueOf(timestamp)); } if (fieldType().indexOptions() != IndexOptions.NONE || fieldType().stored()) { fields.add(new LongFieldMapper.CustomLongNumericField(timestamp, fieldType())); } if (fieldType().hasDocValues()) { - fields.add(new NumericDocValuesField(fieldType().names().indexName(), timestamp)); + fields.add(new NumericDocValuesField(fieldType().name(), timestamp)); } } } diff --git a/core/src/main/java/org/elasticsearch/index/mapper/internal/TypeFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/internal/TypeFieldMapper.java index 15fbd6fd123..05c13d01339 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/internal/TypeFieldMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/internal/TypeFieldMapper.java @@ -70,7 +70,7 @@ public class TypeFieldMapper extends MetadataFieldMapper { FIELD_TYPE.setOmitNorms(true); FIELD_TYPE.setIndexAnalyzer(Lucene.KEYWORD_ANALYZER); FIELD_TYPE.setSearchAnalyzer(Lucene.KEYWORD_ANALYZER); - FIELD_TYPE.setNames(new MappedFieldType.Names(NAME)); + FIELD_TYPE.setName(NAME); FIELD_TYPE.freeze(); } } @@ -84,7 +84,7 @@ public class TypeFieldMapper extends MetadataFieldMapper { @Override public TypeFieldMapper build(BuilderContext context) { - fieldType.setNames(buildNames(context)); + fieldType.setName(buildFullName(context)); return new TypeFieldMapper(fieldType, context.indexSettings()); } } @@ -186,9 +186,9 @@ public class TypeFieldMapper extends MetadataFieldMapper { if (fieldType().indexOptions() == IndexOptions.NONE && !fieldType().stored()) { return; } - fields.add(new Field(fieldType().names().indexName(), context.type(), fieldType())); + fields.add(new Field(fieldType().name(), context.type(), fieldType())); if (fieldType().hasDocValues()) { - fields.add(new SortedSetDocValuesField(fieldType().names().indexName(), new BytesRef(context.type()))); + fields.add(new SortedSetDocValuesField(fieldType().name(), new BytesRef(context.type()))); } } diff --git a/core/src/main/java/org/elasticsearch/index/mapper/internal/UidFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/internal/UidFieldMapper.java index 10f9880d97d..532263b1506 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/internal/UidFieldMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/internal/UidFieldMapper.java @@ -66,7 +66,7 @@ public class UidFieldMapper extends MetadataFieldMapper { FIELD_TYPE.setOmitNorms(true); FIELD_TYPE.setIndexAnalyzer(Lucene.KEYWORD_ANALYZER); FIELD_TYPE.setSearchAnalyzer(Lucene.KEYWORD_ANALYZER); - FIELD_TYPE.setNames(new MappedFieldType.Names(NAME)); + FIELD_TYPE.setName(NAME); FIELD_TYPE.freeze(); NESTED_FIELD_TYPE = FIELD_TYPE.clone(); @@ -193,7 +193,7 @@ public class UidFieldMapper extends MetadataFieldMapper { } public Term term(String uid) { - return new Term(fieldType().names().indexName(), fieldType().indexedValueForSearch(uid)); + return new Term(fieldType().name(), fieldType().indexedValueForSearch(uid)); } @Override diff --git a/core/src/main/java/org/elasticsearch/index/mapper/internal/VersionFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/internal/VersionFieldMapper.java index 6b1471afda7..e9577b9d509 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/internal/VersionFieldMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/internal/VersionFieldMapper.java @@ -51,7 +51,7 @@ public class VersionFieldMapper extends MetadataFieldMapper { public static final MappedFieldType FIELD_TYPE = new VersionFieldType(); static { - FIELD_TYPE.setNames(new MappedFieldType.Names(NAME)); + FIELD_TYPE.setName(NAME); FIELD_TYPE.setDocValuesType(DocValuesType.NUMERIC); FIELD_TYPE.setHasDocValues(true); FIELD_TYPE.freeze(); diff --git a/core/src/main/java/org/elasticsearch/index/mapper/ip/IpFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/ip/IpFieldMapper.java index 598e1d365fd..9984463ffc0 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/ip/IpFieldMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/ip/IpFieldMapper.java @@ -229,7 +229,7 @@ public class IpFieldMapper extends NumberFieldMapper { @Override public Query rangeQuery(Object lowerTerm, Object upperTerm, boolean includeLower, boolean includeUpper) { - return NumericRangeQuery.newLongRange(names().indexName(), numericPrecisionStep(), + return NumericRangeQuery.newLongRange(name(), numericPrecisionStep(), lowerTerm == null ? null : parseValue(lowerTerm), upperTerm == null ? null : parseValue(upperTerm), includeLower, includeUpper); @@ -244,7 +244,7 @@ public class IpFieldMapper extends NumberFieldMapper { } catch (IllegalArgumentException e) { iSim = fuzziness.asLong(); } - return NumericRangeQuery.newLongRange(names().indexName(), numericPrecisionStep(), + return NumericRangeQuery.newLongRange(name(), numericPrecisionStep(), iValue - iSim, iValue + iSim, true, true); @@ -287,7 +287,7 @@ public class IpFieldMapper extends NumberFieldMapper { return; } if (context.includeInAll(includeInAll, this)) { - context.allEntries().addText(fieldType().names().fullName(), ipAsString, fieldType().boost()); + context.allEntries().addText(fieldType().name(), ipAsString, fieldType().boost()); } final long value = ipToLong(ipAsString); diff --git a/core/src/main/java/org/elasticsearch/index/percolator/QueriesLoaderCollector.java b/core/src/main/java/org/elasticsearch/index/percolator/QueriesLoaderCollector.java index 26b52f773e9..c79c7d7da25 100644 --- a/core/src/main/java/org/elasticsearch/index/percolator/QueriesLoaderCollector.java +++ b/core/src/main/java/org/elasticsearch/index/percolator/QueriesLoaderCollector.java @@ -54,7 +54,7 @@ final class QueriesLoaderCollector extends SimpleCollector { QueriesLoaderCollector(PercolatorQueriesRegistry percolator, ESLogger logger, MapperService mapperService, IndexFieldDataService indexFieldDataService) { this.percolator = percolator; this.logger = logger; - final MappedFieldType uidMapper = mapperService.smartNameFieldType(UidFieldMapper.NAME); + final MappedFieldType uidMapper = mapperService.fullName(UidFieldMapper.NAME); this.uidFieldData = indexFieldDataService.getForField(uidMapper); } diff --git a/core/src/main/java/org/elasticsearch/index/query/CommonTermsQueryBuilder.java b/core/src/main/java/org/elasticsearch/index/query/CommonTermsQueryBuilder.java index 20d0b62b725..550ffe89882 100644 --- a/core/src/main/java/org/elasticsearch/index/query/CommonTermsQueryBuilder.java +++ b/core/src/main/java/org/elasticsearch/index/query/CommonTermsQueryBuilder.java @@ -235,7 +235,7 @@ public class CommonTermsQueryBuilder extends AbstractQueryBuilder if (fieldNamesFieldType.isEnabled()) { final String f; if (fieldType != null) { - f = fieldType.names().indexName(); + f = fieldType.name(); } else { f = field; } diff --git a/core/src/main/java/org/elasticsearch/index/query/FieldMaskingSpanQueryBuilder.java b/core/src/main/java/org/elasticsearch/index/query/FieldMaskingSpanQueryBuilder.java index e9258d7cfc1..9ce592ca4cf 100644 --- a/core/src/main/java/org/elasticsearch/index/query/FieldMaskingSpanQueryBuilder.java +++ b/core/src/main/java/org/elasticsearch/index/query/FieldMaskingSpanQueryBuilder.java @@ -87,7 +87,7 @@ public class FieldMaskingSpanQueryBuilder extends AbstractQueryBuilder { MappedFieldType fieldType = context.fieldMapper(fieldName); String indexFieldName; if (fieldType != null) { - indexFieldName = fieldType.names().indexName(); + indexFieldName = fieldType.name(); } else { indexFieldName = fieldName; } diff --git a/core/src/main/java/org/elasticsearch/index/query/WildcardQueryBuilder.java b/core/src/main/java/org/elasticsearch/index/query/WildcardQueryBuilder.java index 7c3cc1c30a3..314bc6faeb2 100644 --- a/core/src/main/java/org/elasticsearch/index/query/WildcardQueryBuilder.java +++ b/core/src/main/java/org/elasticsearch/index/query/WildcardQueryBuilder.java @@ -118,7 +118,7 @@ public class WildcardQueryBuilder extends AbstractQueryBuilder ext @Override protected String getFieldName() { - return fieldData.getFieldNames().fullName(); + return fieldData.getFieldName(); } @Override @@ -450,7 +450,7 @@ public abstract class DecayFunctionBuilder ext @Override protected String getFieldName() { - return fieldData.getFieldNames().fullName(); + return fieldData.getFieldName(); } @Override diff --git a/core/src/main/java/org/elasticsearch/index/query/functionscore/fieldvaluefactor/FieldValueFactorFunctionBuilder.java b/core/src/main/java/org/elasticsearch/index/query/functionscore/fieldvaluefactor/FieldValueFactorFunctionBuilder.java index 4a73d4b2bec..d686e78635b 100644 --- a/core/src/main/java/org/elasticsearch/index/query/functionscore/fieldvaluefactor/FieldValueFactorFunctionBuilder.java +++ b/core/src/main/java/org/elasticsearch/index/query/functionscore/fieldvaluefactor/FieldValueFactorFunctionBuilder.java @@ -148,7 +148,7 @@ public class FieldValueFactorFunctionBuilder extends ScoreFunctionBuilder()); } diff --git a/core/src/main/java/org/elasticsearch/index/search/geo/GeoDistanceRangeQuery.java b/core/src/main/java/org/elasticsearch/index/search/geo/GeoDistanceRangeQuery.java index ea8ff8ca6d3..6f92e411c00 100644 --- a/core/src/main/java/org/elasticsearch/index/search/geo/GeoDistanceRangeQuery.java +++ b/core/src/main/java/org/elasticsearch/index/search/geo/GeoDistanceRangeQuery.java @@ -123,7 +123,7 @@ public class GeoDistanceRangeQuery extends Query { } public String fieldName() { - return indexFieldData.getFieldNames().indexName(); + return indexFieldData.getFieldName(); } @Override @@ -198,7 +198,7 @@ public class GeoDistanceRangeQuery extends Query { if (Double.compare(filter.inclusiveUpperPoint, inclusiveUpperPoint) != 0) return false; if (Double.compare(filter.lat, lat) != 0) return false; if (Double.compare(filter.lon, lon) != 0) return false; - if (!indexFieldData.getFieldNames().indexName().equals(filter.indexFieldData.getFieldNames().indexName())) + if (!indexFieldData.getFieldName().equals(filter.indexFieldData.getFieldName())) return false; if (geoDistance != filter.geoDistance) return false; @@ -207,7 +207,7 @@ public class GeoDistanceRangeQuery extends Query { @Override public String toString(String field) { - return "GeoDistanceRangeQuery(" + indexFieldData.getFieldNames().indexName() + ", " + geoDistance + ", [" + inclusiveLowerPoint + " - " + inclusiveUpperPoint + "], " + lat + ", " + lon + ")"; + return "GeoDistanceRangeQuery(" + indexFieldData.getFieldName() + ", " + geoDistance + ", [" + inclusiveLowerPoint + " - " + inclusiveUpperPoint + "], " + lat + ", " + lon + ")"; } @Override @@ -223,7 +223,7 @@ public class GeoDistanceRangeQuery extends Query { temp = inclusiveUpperPoint != +0.0d ? Double.doubleToLongBits(inclusiveUpperPoint) : 0L; result = 31 * result + Long.hashCode(temp); result = 31 * result + (geoDistance != null ? geoDistance.hashCode() : 0); - result = 31 * result + indexFieldData.getFieldNames().indexName().hashCode(); + result = 31 * result + indexFieldData.getFieldName().hashCode(); return result; } diff --git a/core/src/main/java/org/elasticsearch/index/search/geo/GeoPolygonQuery.java b/core/src/main/java/org/elasticsearch/index/search/geo/GeoPolygonQuery.java index 71e369cce0b..d62aa76efd9 100644 --- a/core/src/main/java/org/elasticsearch/index/search/geo/GeoPolygonQuery.java +++ b/core/src/main/java/org/elasticsearch/index/search/geo/GeoPolygonQuery.java @@ -51,7 +51,7 @@ public class GeoPolygonQuery extends Query { } public String fieldName() { - return indexFieldData.getFieldNames().indexName(); + return indexFieldData.getFieldName(); } @Override @@ -104,7 +104,7 @@ public class GeoPolygonQuery extends Query { @Override public String toString(String field) { StringBuilder sb = new StringBuilder("GeoPolygonQuery("); - sb.append(indexFieldData.getFieldNames().indexName()); + sb.append(indexFieldData.getFieldName()); sb.append(", ").append(Arrays.toString(points)).append(')'); return sb.toString(); } @@ -115,14 +115,14 @@ public class GeoPolygonQuery extends Query { return false; } GeoPolygonQuery that = (GeoPolygonQuery) obj; - return indexFieldData.getFieldNames().indexName().equals(that.indexFieldData.getFieldNames().indexName()) + return indexFieldData.getFieldName().equals(that.indexFieldData.getFieldName()) && Arrays.equals(points, that.points); } @Override public int hashCode() { int h = super.hashCode(); - h = 31 * h + indexFieldData.getFieldNames().indexName().hashCode(); + h = 31 * h + indexFieldData.getFieldName().hashCode(); h = 31 * h + Arrays.hashCode(points); return h; } diff --git a/core/src/main/java/org/elasticsearch/index/search/geo/InMemoryGeoBoundingBoxQuery.java b/core/src/main/java/org/elasticsearch/index/search/geo/InMemoryGeoBoundingBoxQuery.java index a2e9e1b689d..2f2801a2abe 100644 --- a/core/src/main/java/org/elasticsearch/index/search/geo/InMemoryGeoBoundingBoxQuery.java +++ b/core/src/main/java/org/elasticsearch/index/search/geo/InMemoryGeoBoundingBoxQuery.java @@ -57,7 +57,7 @@ public class InMemoryGeoBoundingBoxQuery extends Query { } public String fieldName() { - return indexFieldData.getFieldNames().indexName(); + return indexFieldData.getFieldName(); } @Override @@ -79,7 +79,7 @@ public class InMemoryGeoBoundingBoxQuery extends Query { @Override public String toString(String field) { - return "GeoBoundingBoxFilter(" + indexFieldData.getFieldNames().indexName() + ", " + topLeft + ", " + bottomRight + ")"; + return "GeoBoundingBoxFilter(" + indexFieldData.getFieldName() + ", " + topLeft + ", " + bottomRight + ")"; } @Override diff --git a/core/src/main/java/org/elasticsearch/index/search/geo/IndexedGeoBoundingBoxQuery.java b/core/src/main/java/org/elasticsearch/index/search/geo/IndexedGeoBoundingBoxQuery.java index 43fe1441ced..436fc80d521 100644 --- a/core/src/main/java/org/elasticsearch/index/search/geo/IndexedGeoBoundingBoxQuery.java +++ b/core/src/main/java/org/elasticsearch/index/search/geo/IndexedGeoBoundingBoxQuery.java @@ -32,7 +32,7 @@ public class IndexedGeoBoundingBoxQuery { public static Query create(GeoPoint topLeft, GeoPoint bottomRight, GeoPointFieldMapperLegacy.GeoPointFieldType fieldType) { if (!fieldType.isLatLonEnabled()) { - throw new IllegalArgumentException("lat/lon is not enabled (indexed) for field [" + fieldType.names().fullName() + "], can't use indexed filter on it"); + throw new IllegalArgumentException("lat/lon is not enabled (indexed) for field [" + fieldType.name() + "], can't use indexed filter on it"); } //checks to see if bounding box crosses 180 degrees if (topLeft.lon() > bottomRight.lon()) { diff --git a/core/src/main/java/org/elasticsearch/index/similarity/SimilarityService.java b/core/src/main/java/org/elasticsearch/index/similarity/SimilarityService.java index 1d08683f47b..67cc3b764e3 100644 --- a/core/src/main/java/org/elasticsearch/index/similarity/SimilarityService.java +++ b/core/src/main/java/org/elasticsearch/index/similarity/SimilarityService.java @@ -129,7 +129,7 @@ public final class SimilarityService extends AbstractIndexComponent { @Override public Similarity get(String name) { - MappedFieldType fieldType = mapperService.smartNameFieldType(name); + MappedFieldType fieldType = mapperService.fullName(name); return (fieldType != null && fieldType.similarity() != null) ? fieldType.similarity().get() : defaultSimilarity; } } diff --git a/core/src/main/java/org/elasticsearch/index/termvectors/TermVectorsService.java b/core/src/main/java/org/elasticsearch/index/termvectors/TermVectorsService.java index 0a8a8a7addf..17777756056 100644 --- a/core/src/main/java/org/elasticsearch/index/termvectors/TermVectorsService.java +++ b/core/src/main/java/org/elasticsearch/index/termvectors/TermVectorsService.java @@ -188,7 +188,7 @@ public class TermVectorsService { /* only keep valid fields */ Set validFields = new HashSet<>(); for (String field : selectedFields) { - MappedFieldType fieldType = indexShard.mapperService().smartNameFieldType(field); + MappedFieldType fieldType = indexShard.mapperService().fullName(field); if (!isValidField(fieldType)) { continue; } @@ -223,7 +223,7 @@ public class TermVectorsService { if (perFieldAnalyzer != null && perFieldAnalyzer.containsKey(field)) { analyzer = mapperService.analysisService().analyzer(perFieldAnalyzer.get(field).toString()); } else { - analyzer = mapperService.smartNameFieldType(field).indexAnalyzer(); + analyzer = mapperService.fullName(field).indexAnalyzer(); } if (analyzer == null) { analyzer = mapperService.analysisService().defaultIndexAnalyzer(); @@ -269,7 +269,7 @@ public class TermVectorsService { Set seenFields = new HashSet<>(); Collection getFields = new HashSet<>(); for (IndexableField field : doc.getFields()) { - MappedFieldType fieldType = indexShard.mapperService().smartNameFieldType(field.name()); + MappedFieldType fieldType = indexShard.mapperService().fullName(field.name()); if (!isValidField(fieldType)) { continue; } diff --git a/core/src/main/java/org/elasticsearch/indices/fielddata/cache/IndicesFieldDataCache.java b/core/src/main/java/org/elasticsearch/indices/fielddata/cache/IndicesFieldDataCache.java index 73095f8ee5d..9181c6248ea 100644 --- a/core/src/main/java/org/elasticsearch/indices/fielddata/cache/IndicesFieldDataCache.java +++ b/core/src/main/java/org/elasticsearch/indices/fielddata/cache/IndicesFieldDataCache.java @@ -41,7 +41,6 @@ import org.elasticsearch.index.fielddata.AtomicFieldData; import org.elasticsearch.index.fielddata.FieldDataType; import org.elasticsearch.index.fielddata.IndexFieldData; import org.elasticsearch.index.fielddata.IndexFieldDataCache; -import org.elasticsearch.index.mapper.MappedFieldType; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.index.shard.ShardUtils; import org.elasticsearch.threadpool.ThreadPool; @@ -91,8 +90,8 @@ public class IndicesFieldDataCache extends AbstractComponent implements RemovalL this.closed = true; } - public IndexFieldDataCache buildIndexFieldDataCache(IndexFieldDataCache.Listener listener, Index index, MappedFieldType.Names fieldNames, FieldDataType fieldDataType) { - return new IndexFieldCache(logger, cache, index, fieldNames, fieldDataType, indicesFieldDataCacheListener, listener); + public IndexFieldDataCache buildIndexFieldDataCache(IndexFieldDataCache.Listener listener, Index index, String fieldName, FieldDataType fieldDataType) { + return new IndexFieldCache(logger, cache, index, fieldName, fieldDataType, indicesFieldDataCacheListener, listener); } public Cache getCache() { @@ -107,7 +106,7 @@ public class IndicesFieldDataCache extends AbstractComponent implements RemovalL final Accountable value = notification.getValue(); for (IndexFieldDataCache.Listener listener : key.listeners) { try { - listener.onRemoval(key.shardId, indexCache.fieldNames, indexCache.fieldDataType, notification.getRemovalReason() == RemovalNotification.RemovalReason.EVICTED, value.ramBytesUsed()); + listener.onRemoval(key.shardId, indexCache.fieldName, indexCache.fieldDataType, notification.getRemovalReason() == RemovalNotification.RemovalReason.EVICTED, value.ramBytesUsed()); } catch (Throwable e) { // load anyway since listeners should not throw exceptions logger.error("Failed to call listener on field data cache unloading", e); @@ -129,16 +128,16 @@ public class IndicesFieldDataCache extends AbstractComponent implements RemovalL static class IndexFieldCache implements IndexFieldDataCache, SegmentReader.CoreClosedListener, IndexReader.ReaderClosedListener { private final ESLogger logger; final Index index; - final MappedFieldType.Names fieldNames; + final String fieldName; final FieldDataType fieldDataType; private final Cache cache; private final Listener[] listeners; - IndexFieldCache(ESLogger logger,final Cache cache, Index index, MappedFieldType.Names fieldNames, FieldDataType fieldDataType, Listener... listeners) { + IndexFieldCache(ESLogger logger,final Cache cache, Index index, String fieldName, FieldDataType fieldDataType, Listener... listeners) { this.logger = logger; this.listeners = listeners; this.index = index; - this.fieldNames = fieldNames; + this.fieldName = fieldName; this.fieldDataType = fieldDataType; this.cache = cache; } @@ -156,7 +155,7 @@ public class IndicesFieldDataCache extends AbstractComponent implements RemovalL final AtomicFieldData fieldData = indexFieldData.loadDirect(context); for (Listener listener : k.listeners) { try { - listener.onCache(shardId, fieldNames, fieldDataType, fieldData); + listener.onCache(shardId, fieldName, fieldDataType, fieldData); } catch (Throwable e) { // load anyway since listeners should not throw exceptions logger.error("Failed to call listener on atomic field data loading", e); @@ -180,7 +179,7 @@ public class IndicesFieldDataCache extends AbstractComponent implements RemovalL final Accountable ifd = (Accountable) indexFieldData.localGlobalDirect(indexReader); for (Listener listener : k.listeners) { try { - listener.onCache(shardId, fieldNames, fieldDataType, ifd); + listener.onCache(shardId, fieldName, fieldDataType, ifd); } catch (Throwable e) { // load anyway since listeners should not throw exceptions logger.error("Failed to call listener on global ordinals loading", e); @@ -218,7 +217,7 @@ public class IndicesFieldDataCache extends AbstractComponent implements RemovalL public void clear(String fieldName) { for (Key key : cache.keys()) { if (key.indexCache.index.equals(index)) { - if (key.indexCache.fieldNames.fullName().equals(fieldName)) { + if (key.indexCache.fieldName.equals(fieldName)) { cache.invalidate(key); } } diff --git a/core/src/main/java/org/elasticsearch/indices/fielddata/cache/IndicesFieldDataCacheListener.java b/core/src/main/java/org/elasticsearch/indices/fielddata/cache/IndicesFieldDataCacheListener.java index 06257806af5..c37cf6def79 100644 --- a/core/src/main/java/org/elasticsearch/indices/fielddata/cache/IndicesFieldDataCacheListener.java +++ b/core/src/main/java/org/elasticsearch/indices/fielddata/cache/IndicesFieldDataCacheListener.java @@ -24,7 +24,6 @@ import org.elasticsearch.common.breaker.CircuitBreaker; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.index.fielddata.FieldDataType; import org.elasticsearch.index.fielddata.IndexFieldDataCache; -import org.elasticsearch.index.mapper.MappedFieldType; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.indices.breaker.CircuitBreakerService; @@ -44,11 +43,11 @@ public class IndicesFieldDataCacheListener implements IndexFieldDataCache.Listen } @Override - public void onCache(ShardId shardId, MappedFieldType.Names fieldNames, FieldDataType fieldDataType, Accountable fieldData) { + public void onCache(ShardId shardId, String fieldName, FieldDataType fieldDataType, Accountable fieldData) { } @Override - public void onRemoval(ShardId shardId, MappedFieldType.Names fieldNames, FieldDataType fieldDataType, boolean wasEvicted, long sizeInBytes) { + public void onRemoval(ShardId shardId, String fieldName, FieldDataType fieldDataType, boolean wasEvicted, long sizeInBytes) { assert sizeInBytes >= 0 : "When reducing circuit breaker, it should be adjusted with a number higher or equal to 0 and not [" + sizeInBytes + "]"; circuitBreakerService.getBreaker(CircuitBreaker.FIELDDATA).addWithoutBreaking(-sizeInBytes); } diff --git a/core/src/main/java/org/elasticsearch/indices/ttl/IndicesTTLService.java b/core/src/main/java/org/elasticsearch/indices/ttl/IndicesTTLService.java index a7f931129fe..4f48e4f7b93 100644 --- a/core/src/main/java/org/elasticsearch/indices/ttl/IndicesTTLService.java +++ b/core/src/main/java/org/elasticsearch/indices/ttl/IndicesTTLService.java @@ -196,7 +196,7 @@ public class IndicesTTLService extends AbstractLifecycleComponent shardsToPurge) { for (IndexShard shardToPurge : shardsToPurge) { - Query query = shardToPurge.mapperService().smartNameFieldType(TTLFieldMapper.NAME).rangeQuery(null, System.currentTimeMillis(), false, true); + Query query = shardToPurge.mapperService().fullName(TTLFieldMapper.NAME).rangeQuery(null, System.currentTimeMillis(), false, true); Engine.Searcher searcher = shardToPurge.acquireSearcher("indices_ttl"); try { logger.debug("[{}][{}] purging shard", shardToPurge.routingEntry().index(), shardToPurge.routingEntry().id()); diff --git a/core/src/main/java/org/elasticsearch/percolator/PercolateContext.java b/core/src/main/java/org/elasticsearch/percolator/PercolateContext.java index 7e2103fff93..267ea7a50bf 100644 --- a/core/src/main/java/org/elasticsearch/percolator/PercolateContext.java +++ b/core/src/main/java/org/elasticsearch/percolator/PercolateContext.java @@ -637,12 +637,7 @@ public class PercolateContext extends SearchContext { @Override public MappedFieldType smartNameFieldType(String name) { - return mapperService().smartNameFieldType(name, types); - } - - @Override - public MappedFieldType smartNameFieldTypeFromAnyType(String name) { - return mapperService().smartNameFieldType(name); + return mapperService().fullName(name); } @Override diff --git a/core/src/main/java/org/elasticsearch/percolator/PercolatorService.java b/core/src/main/java/org/elasticsearch/percolator/PercolatorService.java index 0f0b571ff2d..8cc691b866b 100644 --- a/core/src/main/java/org/elasticsearch/percolator/PercolatorService.java +++ b/core/src/main/java/org/elasticsearch/percolator/PercolatorService.java @@ -760,7 +760,7 @@ public class PercolatorService extends AbstractComponent { hls = new ArrayList<>(topDocs.scoreDocs.length); } - final MappedFieldType uidMapper = context.mapperService().smartNameFieldType(UidFieldMapper.NAME); + final MappedFieldType uidMapper = context.mapperService().fullName(UidFieldMapper.NAME); final IndexFieldData uidFieldData = context.fieldData().getForField(uidMapper); int i = 0; for (ScoreDoc scoreDoc : topDocs.scoreDocs) { diff --git a/core/src/main/java/org/elasticsearch/percolator/QueryCollector.java b/core/src/main/java/org/elasticsearch/percolator/QueryCollector.java index 33a8dc813fe..828ff4f08e4 100644 --- a/core/src/main/java/org/elasticsearch/percolator/QueryCollector.java +++ b/core/src/main/java/org/elasticsearch/percolator/QueryCollector.java @@ -73,7 +73,7 @@ abstract class QueryCollector extends SimpleCollector { this.logger = logger; this.queries = context.percolateQueries(); this.searcher = context.docSearcher(); - final MappedFieldType uidMapper = context.mapperService().smartNameFieldType(UidFieldMapper.NAME); + final MappedFieldType uidMapper = context.mapperService().fullName(UidFieldMapper.NAME); this.uidFieldData = context.fieldData().getForField(uidMapper); this.isNestedDoc = isNestedDoc; diff --git a/core/src/main/java/org/elasticsearch/search/SearchService.java b/core/src/main/java/org/elasticsearch/search/SearchService.java index 6bfd3f08a33..02efa373ab0 100644 --- a/core/src/main/java/org/elasticsearch/search/SearchService.java +++ b/core/src/main/java/org/elasticsearch/search/SearchService.java @@ -971,7 +971,7 @@ public class SearchService extends AbstractLifecycleComponent imp final ObjectSet warmUp = new ObjectHashSet<>(); for (DocumentMapper docMapper : mapperService.docMappers(false)) { for (FieldMapper fieldMapper : docMapper.mappers()) { - final String indexName = fieldMapper.fieldType().names().indexName(); + final String indexName = fieldMapper.fieldType().name(); Loading normsLoading = fieldMapper.fieldType().normsLoading(); if (normsLoading == null) { normsLoading = defaultLoading; @@ -1047,10 +1047,10 @@ public class SearchService extends AbstractLifecycleComponent imp fieldDataType = joinFieldType.fieldDataType(); // TODO: this can be removed in 3.0 when the old parent/child impl is removed: // related to: https://github.com/elastic/elasticsearch/pull/12418 - indexName = fieldMapper.fieldType().names().indexName(); + indexName = fieldMapper.fieldType().name(); } else { fieldDataType = fieldMapper.fieldType().fieldDataType(); - indexName = fieldMapper.fieldType().names().indexName(); + indexName = fieldMapper.fieldType().name(); } if (fieldDataType == null) { @@ -1079,10 +1079,10 @@ public class SearchService extends AbstractLifecycleComponent imp final long start = System.nanoTime(); indexFieldDataService.getForField(fieldType).load(ctx); if (indexShard.warmerService().logger().isTraceEnabled()) { - indexShard.warmerService().logger().trace("warmed fielddata for [{}], took [{}]", fieldType.names().fullName(), TimeValue.timeValueNanos(System.nanoTime() - start)); + indexShard.warmerService().logger().trace("warmed fielddata for [{}], took [{}]", fieldType.name(), TimeValue.timeValueNanos(System.nanoTime() - start)); } } catch (Throwable t) { - indexShard.warmerService().logger().warn("failed to warm-up fielddata for [{}]", t, fieldType.names().fullName()); + indexShard.warmerService().logger().warn("failed to warm-up fielddata for [{}]", t, fieldType.name()); } finally { latch.countDown(); } @@ -1115,10 +1115,10 @@ public class SearchService extends AbstractLifecycleComponent imp fieldDataType = joinFieldType.fieldDataType(); // TODO: this can be removed in 3.0 when the old parent/child impl is removed: // related to: https://github.com/elastic/elasticsearch/pull/12418 - indexName = fieldMapper.fieldType().names().indexName(); + indexName = fieldMapper.fieldType().name(); } else { fieldDataType = fieldMapper.fieldType().fieldDataType(); - indexName = fieldMapper.fieldType().names().indexName(); + indexName = fieldMapper.fieldType().name(); } if (fieldDataType == null) { continue; @@ -1144,10 +1144,10 @@ public class SearchService extends AbstractLifecycleComponent imp IndexFieldData.Global ifd = indexFieldDataService.getForField(fieldType); ifd.loadGlobal(searcher.getDirectoryReader()); if (indexShard.warmerService().logger().isTraceEnabled()) { - indexShard.warmerService().logger().trace("warmed global ordinals for [{}], took [{}]", fieldType.names().fullName(), TimeValue.timeValueNanos(System.nanoTime() - start)); + indexShard.warmerService().logger().trace("warmed global ordinals for [{}], took [{}]", fieldType.name(), TimeValue.timeValueNanos(System.nanoTime() - start)); } } catch (Throwable t) { - indexShard.warmerService().logger().warn("failed to warm-up global ordinals for [{}]", t, fieldType.names().fullName()); + indexShard.warmerService().logger().warn("failed to warm-up global ordinals for [{}]", t, fieldType.name()); } finally { latch.countDown(); } diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/children/ChildrenParser.java b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/children/ChildrenParser.java index 2c597bdcee9..438e872be77 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/children/ChildrenParser.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/children/ChildrenParser.java @@ -88,7 +88,7 @@ public class ChildrenParser implements Aggregator.Parser { parentFilter = parentDocMapper.typeFilter(); childFilter = childDocMapper.typeFilter(); ParentChildIndexFieldData parentChildIndexFieldData = context.fieldData().getForField(parentFieldMapper.fieldType()); - config.fieldContext(new FieldContext(parentFieldMapper.fieldType().names().indexName(), parentChildIndexFieldData, parentFieldMapper.fieldType())); + config.fieldContext(new FieldContext(parentFieldMapper.fieldType().name(), parentChildIndexFieldData, parentFieldMapper.fieldType())); } else { config.unmapped(true); } diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/support/ValuesSourceParser.java b/core/src/main/java/org/elasticsearch/search/aggregations/support/ValuesSourceParser.java index a9dcc77ee9f..fced5fdc913 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/support/ValuesSourceParser.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/support/ValuesSourceParser.java @@ -191,7 +191,7 @@ public class ValuesSourceParser { return config; } - MappedFieldType fieldType = context.smartNameFieldTypeFromAnyType(input.field); + MappedFieldType fieldType = context.smartNameFieldType(input.field); if (fieldType == null) { Class valuesSourceType = valueType != null ? (Class) valueType.getValuesSourceType() : this.valuesSourceType; ValuesSourceConfig config = new ValuesSourceConfig<>(valuesSourceType); diff --git a/core/src/main/java/org/elasticsearch/search/fetch/fielddata/FieldDataFieldsFetchSubPhase.java b/core/src/main/java/org/elasticsearch/search/fetch/fielddata/FieldDataFieldsFetchSubPhase.java index c74ef7b0c73..16b1311809c 100644 --- a/core/src/main/java/org/elasticsearch/search/fetch/fielddata/FieldDataFieldsFetchSubPhase.java +++ b/core/src/main/java/org/elasticsearch/search/fetch/fielddata/FieldDataFieldsFetchSubPhase.java @@ -94,7 +94,7 @@ public class FieldDataFieldsFetchSubPhase implements FetchSubPhase { hitField = new InternalSearchHitField(field.name(), new ArrayList<>(2)); hitContext.hit().fields().put(field.name(), hitField); } - MappedFieldType fieldType = context.mapperService().smartNameFieldType(field.name()); + MappedFieldType fieldType = context.mapperService().fullName(field.name()); if (fieldType != null) { AtomicFieldData data = context.fieldData().getForField(fieldType).load(hitContext.readerContext()); ScriptDocValues values = data.getScriptValues(); diff --git a/core/src/main/java/org/elasticsearch/search/highlight/FastVectorHighlighter.java b/core/src/main/java/org/elasticsearch/search/highlight/FastVectorHighlighter.java index b57899b2e17..51c56e676c1 100644 --- a/core/src/main/java/org/elasticsearch/search/highlight/FastVectorHighlighter.java +++ b/core/src/main/java/org/elasticsearch/search/highlight/FastVectorHighlighter.java @@ -151,10 +151,10 @@ public class FastVectorHighlighter implements Highlighter { // we highlight against the low level reader and docId, because if we load source, we want to reuse it if possible // Only send matched fields if they were requested to save time. if (field.fieldOptions().matchedFields() != null && !field.fieldOptions().matchedFields().isEmpty()) { - fragments = cache.fvh.getBestFragments(fieldQuery, hitContext.reader(), hitContext.docId(), mapper.fieldType().names().indexName(), field.fieldOptions().matchedFields(), fragmentCharSize, + fragments = cache.fvh.getBestFragments(fieldQuery, hitContext.reader(), hitContext.docId(), mapper.fieldType().name(), field.fieldOptions().matchedFields(), fragmentCharSize, numberOfFragments, entry.fragListBuilder, entry.fragmentsBuilder, field.fieldOptions().preTags(), field.fieldOptions().postTags(), encoder); } else { - fragments = cache.fvh.getBestFragments(fieldQuery, hitContext.reader(), hitContext.docId(), mapper.fieldType().names().indexName(), fragmentCharSize, + fragments = cache.fvh.getBestFragments(fieldQuery, hitContext.reader(), hitContext.docId(), mapper.fieldType().name(), fragmentCharSize, numberOfFragments, entry.fragListBuilder, entry.fragmentsBuilder, field.fieldOptions().preTags(), field.fieldOptions().postTags(), encoder); } @@ -167,7 +167,7 @@ public class FastVectorHighlighter implements Highlighter { // Essentially we just request that a fragment is built from 0 to noMatchSize using the normal fragmentsBuilder FieldFragList fieldFragList = new SimpleFieldFragList(-1 /*ignored*/); fieldFragList.add(0, noMatchSize, Collections.emptyList()); - fragments = entry.fragmentsBuilder.createFragments(hitContext.reader(), hitContext.docId(), mapper.fieldType().names().indexName(), + fragments = entry.fragmentsBuilder.createFragments(hitContext.reader(), hitContext.docId(), mapper.fieldType().name(), fieldFragList, 1, field.fieldOptions().preTags(), field.fieldOptions().postTags(), encoder); if (fragments != null && fragments.length > 0) { return new HighlightField(highlighterContext.fieldName, Text.convertFromStringArray(fragments)); diff --git a/core/src/main/java/org/elasticsearch/search/highlight/HighlightUtils.java b/core/src/main/java/org/elasticsearch/search/highlight/HighlightUtils.java index db64af82398..d4095c14ec0 100644 --- a/core/src/main/java/org/elasticsearch/search/highlight/HighlightUtils.java +++ b/core/src/main/java/org/elasticsearch/search/highlight/HighlightUtils.java @@ -48,9 +48,9 @@ public final class HighlightUtils { boolean forceSource = searchContext.highlight().forceSource(field); List textsToHighlight; if (!forceSource && mapper.fieldType().stored()) { - CustomFieldsVisitor fieldVisitor = new CustomFieldsVisitor(singleton(mapper.fieldType().names().indexName()), false); + CustomFieldsVisitor fieldVisitor = new CustomFieldsVisitor(singleton(mapper.fieldType().name()), false); hitContext.reader().document(hitContext.docId(), fieldVisitor); - textsToHighlight = fieldVisitor.fields().get(mapper.fieldType().names().indexName()); + textsToHighlight = fieldVisitor.fields().get(mapper.fieldType().name()); if (textsToHighlight == null) { // Can happen if the document doesn't have the field to highlight textsToHighlight = Collections.emptyList(); @@ -58,7 +58,7 @@ public final class HighlightUtils { } else { SourceLookup sourceLookup = searchContext.lookup().source(); sourceLookup.setSegmentAndDocument(hitContext.readerContext(), hitContext.docId()); - textsToHighlight = sourceLookup.extractRawValues(hitContext.getSourcePath(mapper.fieldType().names().fullName())); + textsToHighlight = sourceLookup.extractRawValues(hitContext.getSourcePath(mapper.fieldType().name())); } assert textsToHighlight != null; return textsToHighlight; diff --git a/core/src/main/java/org/elasticsearch/search/highlight/PlainHighlighter.java b/core/src/main/java/org/elasticsearch/search/highlight/PlainHighlighter.java index 5f4cdddb060..4bd27e11795 100644 --- a/core/src/main/java/org/elasticsearch/search/highlight/PlainHighlighter.java +++ b/core/src/main/java/org/elasticsearch/search/highlight/PlainHighlighter.java @@ -72,7 +72,7 @@ public class PlainHighlighter implements Highlighter { org.apache.lucene.search.highlight.Highlighter entry = cache.get(mapper); if (entry == null) { - QueryScorer queryScorer = new CustomQueryScorer(highlighterContext.query, field.fieldOptions().requireFieldMatch() ? mapper.fieldType().names().indexName() : null); + QueryScorer queryScorer = new CustomQueryScorer(highlighterContext.query, field.fieldOptions().requireFieldMatch() ? mapper.fieldType().name() : null); queryScorer.setExpandMultiTermQuery(true); Fragmenter fragmenter; if (field.fieldOptions().numberOfFragments() == 0) { @@ -108,7 +108,7 @@ public class PlainHighlighter implements Highlighter { for (Object textToHighlight : textsToHighlight) { String text = textToHighlight.toString(); - try (TokenStream tokenStream = analyzer.tokenStream(mapper.fieldType().names().indexName(), text)) { + try (TokenStream tokenStream = analyzer.tokenStream(mapper.fieldType().name(), text)) { if (!tokenStream.hasAttribute(CharTermAttribute.class) || !tokenStream.hasAttribute(OffsetAttribute.class)) { // can't perform highlighting if the stream has no terms (binary token stream) or no offsets continue; @@ -165,7 +165,7 @@ public class PlainHighlighter implements Highlighter { String fieldContents = textsToHighlight.get(0).toString(); int end; try { - end = findGoodEndForNoHighlightExcerpt(noMatchSize, analyzer, mapper.fieldType().names().indexName(), fieldContents); + end = findGoodEndForNoHighlightExcerpt(noMatchSize, analyzer, mapper.fieldType().name(), fieldContents); } catch (Exception e) { throw new FetchPhaseExecutionException(context, "Failed to highlight field [" + highlighterContext.fieldName + "]", e); } diff --git a/core/src/main/java/org/elasticsearch/search/highlight/PostingsHighlighter.java b/core/src/main/java/org/elasticsearch/search/highlight/PostingsHighlighter.java index 2509f95da59..51c460c5c68 100644 --- a/core/src/main/java/org/elasticsearch/search/highlight/PostingsHighlighter.java +++ b/core/src/main/java/org/elasticsearch/search/highlight/PostingsHighlighter.java @@ -93,7 +93,7 @@ public class PostingsHighlighter implements Highlighter { } IndexSearcher searcher = new IndexSearcher(hitContext.reader()); - Snippet[] fieldSnippets = highlighter.highlightField(fieldMapper.fieldType().names().indexName(), highlighterContext.query, searcher, hitContext.docId(), numberOfFragments); + Snippet[] fieldSnippets = highlighter.highlightField(fieldMapper.fieldType().name(), highlighterContext.query, searcher, hitContext.docId(), numberOfFragments); for (Snippet fieldSnippet : fieldSnippets) { if (Strings.hasText(fieldSnippet.getText())) { snippets.add(fieldSnippet); diff --git a/core/src/main/java/org/elasticsearch/search/highlight/vectorhighlight/FragmentBuilderHelper.java b/core/src/main/java/org/elasticsearch/search/highlight/vectorhighlight/FragmentBuilderHelper.java index eb17daec5f1..363a3b9137d 100644 --- a/core/src/main/java/org/elasticsearch/search/highlight/vectorhighlight/FragmentBuilderHelper.java +++ b/core/src/main/java/org/elasticsearch/search/highlight/vectorhighlight/FragmentBuilderHelper.java @@ -55,7 +55,7 @@ public final class FragmentBuilderHelper { */ public static WeightedFragInfo fixWeightedFragInfo(FieldMapper mapper, Field[] values, WeightedFragInfo fragInfo) { assert fragInfo != null : "FragInfo must not be null"; - assert mapper.fieldType().names().indexName().equals(values[0].name()) : "Expected FieldMapper for field " + values[0].name(); + assert mapper.fieldType().name().equals(values[0].name()) : "Expected FieldMapper for field " + values[0].name(); if (!fragInfo.getSubInfos().isEmpty() && (containsBrokenAnalysis(mapper.fieldType().indexAnalyzer()))) { /* This is a special case where broken analysis like WDF is used for term-vector creation at index-time * which can potentially mess up the offsets. To prevent a SAIIOBException we need to resort diff --git a/core/src/main/java/org/elasticsearch/search/highlight/vectorhighlight/SourceScoreOrderFragmentsBuilder.java b/core/src/main/java/org/elasticsearch/search/highlight/vectorhighlight/SourceScoreOrderFragmentsBuilder.java index af914cebf6c..2d226aabf94 100644 --- a/core/src/main/java/org/elasticsearch/search/highlight/vectorhighlight/SourceScoreOrderFragmentsBuilder.java +++ b/core/src/main/java/org/elasticsearch/search/highlight/vectorhighlight/SourceScoreOrderFragmentsBuilder.java @@ -59,10 +59,10 @@ public class SourceScoreOrderFragmentsBuilder extends ScoreOrderFragmentsBuilder SourceLookup sourceLookup = searchContext.lookup().source(); sourceLookup.setSegmentAndDocument((LeafReaderContext) reader.getContext(), docId); - List values = sourceLookup.extractRawValues(hitContext.getSourcePath(mapper.fieldType().names().fullName())); + List values = sourceLookup.extractRawValues(hitContext.getSourcePath(mapper.fieldType().name())); Field[] fields = new Field[values.size()]; for (int i = 0; i < values.size(); i++) { - fields[i] = new Field(mapper.fieldType().names().indexName(), values.get(i).toString(), TextField.TYPE_NOT_STORED); + fields[i] = new Field(mapper.fieldType().name(), values.get(i).toString(), TextField.TYPE_NOT_STORED); } return fields; } diff --git a/core/src/main/java/org/elasticsearch/search/highlight/vectorhighlight/SourceSimpleFragmentsBuilder.java b/core/src/main/java/org/elasticsearch/search/highlight/vectorhighlight/SourceSimpleFragmentsBuilder.java index 222f00a5597..b80c239376e 100644 --- a/core/src/main/java/org/elasticsearch/search/highlight/vectorhighlight/SourceSimpleFragmentsBuilder.java +++ b/core/src/main/java/org/elasticsearch/search/highlight/vectorhighlight/SourceSimpleFragmentsBuilder.java @@ -55,13 +55,13 @@ public class SourceSimpleFragmentsBuilder extends SimpleFragmentsBuilder { SourceLookup sourceLookup = searchContext.lookup().source(); sourceLookup.setSegmentAndDocument((LeafReaderContext) reader.getContext(), docId); - List values = sourceLookup.extractRawValues(hitContext.getSourcePath(mapper.fieldType().names().fullName())); + List values = sourceLookup.extractRawValues(hitContext.getSourcePath(mapper.fieldType().name())); if (values.isEmpty()) { return EMPTY_FIELDS; } Field[] fields = new Field[values.size()]; for (int i = 0; i < values.size(); i++) { - fields[i] = new Field(mapper.fieldType().names().indexName(), values.get(i).toString(), TextField.TYPE_NOT_STORED); + fields[i] = new Field(mapper.fieldType().name(), values.get(i).toString(), TextField.TYPE_NOT_STORED); } return fields; } diff --git a/core/src/main/java/org/elasticsearch/search/internal/DefaultSearchContext.java b/core/src/main/java/org/elasticsearch/search/internal/DefaultSearchContext.java index 8190d5257d9..c3eef7559a0 100644 --- a/core/src/main/java/org/elasticsearch/search/internal/DefaultSearchContext.java +++ b/core/src/main/java/org/elasticsearch/search/internal/DefaultSearchContext.java @@ -699,17 +699,12 @@ public class DefaultSearchContext extends SearchContext { @Override public MappedFieldType smartNameFieldType(String name) { - return mapperService().smartNameFieldType(name, request.types()); - } - - @Override - public MappedFieldType smartNameFieldTypeFromAnyType(String name) { - return mapperService().smartNameFieldType(name); + return mapperService().fullName(name); } @Override public ObjectMapper getObjectMapper(String name) { - return mapperService().getObjectMapper(name, request.types()); + return mapperService().getObjectMapper(name); } @Override diff --git a/core/src/main/java/org/elasticsearch/search/internal/FilteredSearchContext.java b/core/src/main/java/org/elasticsearch/search/internal/FilteredSearchContext.java index 1f04d013401..eaa14933b33 100644 --- a/core/src/main/java/org/elasticsearch/search/internal/FilteredSearchContext.java +++ b/core/src/main/java/org/elasticsearch/search/internal/FilteredSearchContext.java @@ -496,11 +496,6 @@ public abstract class FilteredSearchContext extends SearchContext { return in.smartNameFieldType(name); } - @Override - public MappedFieldType smartNameFieldTypeFromAnyType(String name) { - return in.smartNameFieldTypeFromAnyType(name); - } - @Override public ObjectMapper getObjectMapper(String name) { return in.getObjectMapper(name); diff --git a/core/src/main/java/org/elasticsearch/search/internal/SearchContext.java b/core/src/main/java/org/elasticsearch/search/internal/SearchContext.java index 5c4e70c1004..76164b5c0f8 100644 --- a/core/src/main/java/org/elasticsearch/search/internal/SearchContext.java +++ b/core/src/main/java/org/elasticsearch/search/internal/SearchContext.java @@ -343,12 +343,10 @@ public abstract class SearchContext extends DelegatingHasContextAndHeaders imple } } - public abstract MappedFieldType smartNameFieldType(String name); - /** * Looks up the given field, but does not restrict to fields in the types set on this context. */ - public abstract MappedFieldType smartNameFieldTypeFromAnyType(String name); + public abstract MappedFieldType smartNameFieldType(String name); public abstract ObjectMapper getObjectMapper(String name); diff --git a/core/src/main/java/org/elasticsearch/search/lookup/FieldLookup.java b/core/src/main/java/org/elasticsearch/search/lookup/FieldLookup.java index ec4b5a041ff..249a23b9bfc 100644 --- a/core/src/main/java/org/elasticsearch/search/lookup/FieldLookup.java +++ b/core/src/main/java/org/elasticsearch/search/lookup/FieldLookup.java @@ -85,7 +85,7 @@ public class FieldLookup { } valueLoaded = true; value = null; - List values = fields.get(fieldType.names().indexName()); + List values = fields.get(fieldType.name()); return values != null ? value = values.get(0) : null; } @@ -95,6 +95,6 @@ public class FieldLookup { } valuesLoaded = true; values.clear(); - return values = fields().get(fieldType.names().indexName()); + return values = fields().get(fieldType.name()); } } diff --git a/core/src/main/java/org/elasticsearch/search/lookup/LeafDocLookup.java b/core/src/main/java/org/elasticsearch/search/lookup/LeafDocLookup.java index 3864581034e..db20a03f825 100644 --- a/core/src/main/java/org/elasticsearch/search/lookup/LeafDocLookup.java +++ b/core/src/main/java/org/elasticsearch/search/lookup/LeafDocLookup.java @@ -75,7 +75,7 @@ public class LeafDocLookup implements Map { String fieldName = key.toString(); ScriptDocValues scriptValues = localCacheFieldData.get(fieldName); if (scriptValues == null) { - final MappedFieldType fieldType = mapperService.smartNameFieldType(fieldName, types); + final MappedFieldType fieldType = mapperService.fullName(fieldName); if (fieldType == null) { throw new IllegalArgumentException("No field found for [" + fieldName + "] in mapping with types " + Arrays.toString(types) + ""); } @@ -99,7 +99,7 @@ public class LeafDocLookup implements Map { String fieldName = key.toString(); ScriptDocValues scriptValues = localCacheFieldData.get(fieldName); if (scriptValues == null) { - MappedFieldType fieldType = mapperService.smartNameFieldType(fieldName, types); + MappedFieldType fieldType = mapperService.fullName(fieldName); if (fieldType == null) { return false; } diff --git a/core/src/main/java/org/elasticsearch/search/lookup/LeafFieldsLookup.java b/core/src/main/java/org/elasticsearch/search/lookup/LeafFieldsLookup.java index e5295e80fb3..a5f90aa2c90 100644 --- a/core/src/main/java/org/elasticsearch/search/lookup/LeafFieldsLookup.java +++ b/core/src/main/java/org/elasticsearch/search/lookup/LeafFieldsLookup.java @@ -136,7 +136,7 @@ public class LeafFieldsLookup implements Map { private FieldLookup loadFieldData(String name) { FieldLookup data = cachedFieldData.get(name); if (data == null) { - MappedFieldType fieldType = mapperService.smartNameFieldType(name, types); + MappedFieldType fieldType = mapperService.fullName(name); if (fieldType == null) { throw new IllegalArgumentException("No field found for [" + name + "] in mapping with types " + Arrays.toString(types) + ""); } @@ -144,12 +144,12 @@ public class LeafFieldsLookup implements Map { cachedFieldData.put(name, data); } if (data.fields() == null) { - String fieldName = data.fieldType().names().indexName(); + String fieldName = data.fieldType().name(); fieldVisitor.reset(fieldName); try { reader.document(docId, fieldVisitor); fieldVisitor.postProcess(data.fieldType()); - data.fields(singletonMap(name, fieldVisitor.fields().get(data.fieldType().names().indexName()))); + data.fields(singletonMap(name, fieldVisitor.fields().get(data.fieldType().name()))); } catch (IOException e) { throw new ElasticsearchParseException("failed to load field [{}]", e, name); } diff --git a/core/src/main/java/org/elasticsearch/search/sort/SortParseElement.java b/core/src/main/java/org/elasticsearch/search/sort/SortParseElement.java index 80a9daa53f0..a99158787d3 100644 --- a/core/src/main/java/org/elasticsearch/search/sort/SortParseElement.java +++ b/core/src/main/java/org/elasticsearch/search/sort/SortParseElement.java @@ -253,7 +253,7 @@ public class SortParseElement implements SearchParseElement { IndexFieldData.XFieldComparatorSource fieldComparatorSource = context.fieldData().getForField(fieldType) .comparatorSource(missing, sortMode, nested); - sortFields.add(new SortField(fieldType.names().indexName(), fieldComparatorSource, reverse)); + sortFields.add(new SortField(fieldType.name(), fieldComparatorSource, reverse)); } } diff --git a/core/src/main/java/org/elasticsearch/search/suggest/completion/CompletionSuggestParser.java b/core/src/main/java/org/elasticsearch/search/suggest/completion/CompletionSuggestParser.java index 99842ca77bb..a2e5f743c59 100644 --- a/core/src/main/java/org/elasticsearch/search/suggest/completion/CompletionSuggestParser.java +++ b/core/src/main/java/org/elasticsearch/search/suggest/completion/CompletionSuggestParser.java @@ -140,13 +140,13 @@ public class CompletionSuggestParser implements SuggestContextParser { final ContextAndSuggest contextAndSuggest = new ContextAndSuggest(mapperService); TLP_PARSER.parse(parser, suggestion, contextAndSuggest); final XContentParser contextParser = contextAndSuggest.contextParser; - MappedFieldType mappedFieldType = mapperService.smartNameFieldType(suggestion.getField()); + MappedFieldType mappedFieldType = mapperService.fullName(suggestion.getField()); if (mappedFieldType == null) { throw new ElasticsearchException("Field [" + suggestion.getField() + "] is not a completion suggest field"); } else if (mappedFieldType instanceof CompletionFieldMapper.CompletionFieldType) { CompletionFieldMapper.CompletionFieldType type = (CompletionFieldMapper.CompletionFieldType) mappedFieldType; if (type.hasContextMappings() == false && contextParser != null) { - throw new IllegalArgumentException("suggester [" + type.names().fullName() + "] doesn't expect any context"); + throw new IllegalArgumentException("suggester [" + type.name() + "] doesn't expect any context"); } Map> queryContexts = Collections.emptyMap(); if (type.hasContextMappings() && contextParser != null) { diff --git a/core/src/main/java/org/elasticsearch/search/suggest/completion/CompletionSuggester.java b/core/src/main/java/org/elasticsearch/search/suggest/completion/CompletionSuggester.java index 75211e85205..527a35658c9 100644 --- a/core/src/main/java/org/elasticsearch/search/suggest/completion/CompletionSuggester.java +++ b/core/src/main/java/org/elasticsearch/search/suggest/completion/CompletionSuggester.java @@ -84,7 +84,7 @@ public class CompletionSuggester extends Suggester final LeafReaderContext subReaderContext = leaves.get(readerIndex); final int subDocId = suggestDoc.doc - subReaderContext.docBase; for (String field : payloadFields) { - MappedFieldType payloadFieldType = suggestionContext.getMapperService().smartNameFieldType(field); + MappedFieldType payloadFieldType = suggestionContext.getMapperService().fullName(field); if (payloadFieldType != null) { final AtomicFieldData data = suggestionContext.getIndexFieldDataService().getForField(payloadFieldType).load(subReaderContext); final ScriptDocValues scriptValues = data.getScriptValues(); diff --git a/core/src/main/java/org/elasticsearch/search/suggest/phrase/PhraseSuggestParser.java b/core/src/main/java/org/elasticsearch/search/suggest/phrase/PhraseSuggestParser.java index 9b083a91788..0b904a95720 100644 --- a/core/src/main/java/org/elasticsearch/search/suggest/phrase/PhraseSuggestParser.java +++ b/core/src/main/java/org/elasticsearch/search/suggest/phrase/PhraseSuggestParser.java @@ -171,7 +171,7 @@ public final class PhraseSuggestParser implements SuggestContextParser { throw new IllegalArgumentException("The required field option is missing"); } - MappedFieldType fieldType = mapperService.smartNameFieldType(suggestion.getField()); + MappedFieldType fieldType = mapperService.fullName(suggestion.getField()); if (fieldType == null) { throw new IllegalArgumentException("No mapping found for field [" + suggestion.getField() + "]"); } else if (suggestion.getAnalyzer() == null) { @@ -329,7 +329,7 @@ public final class PhraseSuggestParser implements SuggestContextParser { if (!SuggestUtils.parseDirectSpellcheckerSettings(parser, fieldName, generator, parseFieldMatcher)) { if ("field".equals(fieldName)) { generator.setField(parser.text()); - if (mapperService.smartNameFieldType(generator.field()) == null) { + if (mapperService.fullName(generator.field()) == null) { throw new IllegalArgumentException("No mapping found for field [" + generator.field() + "]"); } } else if ("size".equals(fieldName)) { diff --git a/core/src/test/java/org/elasticsearch/index/fielddata/FieldDataCacheTests.java b/core/src/test/java/org/elasticsearch/index/fielddata/FieldDataCacheTests.java index b3485f3f212..13f7f74e37b 100644 --- a/core/src/test/java/org/elasticsearch/index/fielddata/FieldDataCacheTests.java +++ b/core/src/test/java/org/elasticsearch/index/fielddata/FieldDataCacheTests.java @@ -90,14 +90,12 @@ public class FieldDataCacheTests extends ESTestCase { private SortedSetDVOrdinalsIndexFieldData createSortedDV(String fieldName, IndexFieldDataCache indexFieldDataCache) { FieldDataType fieldDataType = new StringFieldMapper.StringFieldType().fieldDataType(); - MappedFieldType.Names names = new MappedFieldType.Names(fieldName); - return new SortedSetDVOrdinalsIndexFieldData(createIndexSettings(), indexFieldDataCache, names, new NoneCircuitBreakerService(), fieldDataType); + return new SortedSetDVOrdinalsIndexFieldData(createIndexSettings(), indexFieldDataCache, fieldName, new NoneCircuitBreakerService(), fieldDataType); } private PagedBytesIndexFieldData createPagedBytes(String fieldName, IndexFieldDataCache indexFieldDataCache) { FieldDataType fieldDataType = new StringFieldMapper.StringFieldType().fieldDataType(); - MappedFieldType.Names names = new MappedFieldType.Names(fieldName); - return new PagedBytesIndexFieldData(createIndexSettings(), names, fieldDataType, indexFieldDataCache, new NoneCircuitBreakerService()); + return new PagedBytesIndexFieldData(createIndexSettings(), fieldName, fieldDataType, indexFieldDataCache, new NoneCircuitBreakerService()); } private IndexSettings createIndexSettings() { diff --git a/core/src/test/java/org/elasticsearch/index/fielddata/IndexFieldDataServiceTests.java b/core/src/test/java/org/elasticsearch/index/fielddata/IndexFieldDataServiceTests.java index c9ac901d44f..3d4f63daa33 100644 --- a/core/src/test/java/org/elasticsearch/index/fielddata/IndexFieldDataServiceTests.java +++ b/core/src/test/java/org/elasticsearch/index/fielddata/IndexFieldDataServiceTests.java @@ -41,7 +41,6 @@ import org.elasticsearch.index.fielddata.plain.SortedNumericDVIndexFieldData; import org.elasticsearch.index.fielddata.plain.SortedSetDVOrdinalsIndexFieldData; import org.elasticsearch.index.mapper.ContentPath; import org.elasticsearch.index.mapper.MappedFieldType; -import org.elasticsearch.index.mapper.MappedFieldType.Names; import org.elasticsearch.index.mapper.Mapper.BuilderContext; import org.elasticsearch.index.mapper.MapperBuilders; import org.elasticsearch.index.mapper.core.BooleanFieldMapper; @@ -151,7 +150,7 @@ public class IndexFieldDataServiceTests extends ESSingleNodeTestCase { final AtomicInteger onRemovalCalled = new AtomicInteger(); ifdService.setListener(new IndexFieldDataCache.Listener() { @Override - public void onCache(ShardId shardId, MappedFieldType.Names fieldNames, FieldDataType fieldDataType, Accountable ramUsage) { + public void onCache(ShardId shardId, String fieldName, FieldDataType fieldDataType, Accountable ramUsage) { if (wrap) { assertEquals(new ShardId("test", 1), shardId); } else { @@ -161,7 +160,7 @@ public class IndexFieldDataServiceTests extends ESSingleNodeTestCase { } @Override - public void onRemoval(ShardId shardId, MappedFieldType.Names fieldNames, FieldDataType fieldDataType, boolean wasEvicted, long sizeInBytes) { + public void onRemoval(ShardId shardId, String fieldName, FieldDataType fieldDataType, boolean wasEvicted, long sizeInBytes) { if (wrap) { assertEquals(new ShardId("test", 1), shardId); } else { @@ -189,12 +188,12 @@ public class IndexFieldDataServiceTests extends ESSingleNodeTestCase { try { shardPrivateService.setListener(new IndexFieldDataCache.Listener() { @Override - public void onCache(ShardId shardId, MappedFieldType.Names fieldNames, FieldDataType fieldDataType, Accountable ramUsage) { + public void onCache(ShardId shardId, String fieldName, FieldDataType fieldDataType, Accountable ramUsage) { } @Override - public void onRemoval(ShardId shardId, MappedFieldType.Names fieldNames, FieldDataType fieldDataType, boolean wasEvicted, long sizeInBytes) { + public void onRemoval(ShardId shardId, String fieldName, FieldDataType fieldDataType, boolean wasEvicted, long sizeInBytes) { } }); @@ -209,7 +208,7 @@ public class IndexFieldDataServiceTests extends ESSingleNodeTestCase { try { IndicesFieldDataCache cache = new IndicesFieldDataCache(Settings.EMPTY, null, threadPool); IndexFieldDataService ifds = new IndexFieldDataService(IndexSettingsModule.newIndexSettings(new Index("test"), Settings.EMPTY), cache, null, null); - ft.setNames(new Names("some_long")); + ft.setName("some_long"); ft.setHasDocValues(true); ifds.getForField(ft); // no exception ft.setHasDocValues(false); diff --git a/core/src/test/java/org/elasticsearch/index/fielddata/NoOrdinalsStringFieldDataTests.java b/core/src/test/java/org/elasticsearch/index/fielddata/NoOrdinalsStringFieldDataTests.java index 561252a5c71..f1fb694b295 100644 --- a/core/src/test/java/org/elasticsearch/index/fielddata/NoOrdinalsStringFieldDataTests.java +++ b/core/src/test/java/org/elasticsearch/index/fielddata/NoOrdinalsStringFieldDataTests.java @@ -23,7 +23,6 @@ import org.apache.lucene.index.LeafReaderContext; import org.elasticsearch.index.Index; import org.elasticsearch.index.fielddata.IndexFieldData.XFieldComparatorSource.Nested; import org.elasticsearch.index.fielddata.fieldcomparator.BytesRefFieldComparatorSource; -import org.elasticsearch.index.mapper.MappedFieldType.Names; import org.elasticsearch.search.MultiValueMode; /** Returns an implementation based on paged bytes which doesn't implement WithOrdinals in order to visit different paths in the code, @@ -39,8 +38,8 @@ public class NoOrdinalsStringFieldDataTests extends PagedBytesStringFieldDataTes } @Override - public Names getFieldNames() { - return in.getFieldNames(); + public String getFieldName() { + return in.getFieldName(); } @Override diff --git a/core/src/test/java/org/elasticsearch/index/mapper/DocumentFieldMapperTests.java b/core/src/test/java/org/elasticsearch/index/mapper/DocumentFieldMapperTests.java index 90976dac4b1..06307614a51 100644 --- a/core/src/test/java/org/elasticsearch/index/mapper/DocumentFieldMapperTests.java +++ b/core/src/test/java/org/elasticsearch/index/mapper/DocumentFieldMapperTests.java @@ -109,14 +109,14 @@ public class DocumentFieldMapperTests extends LuceneTestCase { public void testAnalyzers() throws IOException { FakeFieldType fieldType1 = new FakeFieldType(); - fieldType1.setNames(new MappedFieldType.Names("field1")); + fieldType1.setName("field1"); fieldType1.setIndexAnalyzer(new NamedAnalyzer("foo", new FakeAnalyzer("index"))); fieldType1.setSearchAnalyzer(new NamedAnalyzer("bar", new FakeAnalyzer("search"))); fieldType1.setSearchQuoteAnalyzer(new NamedAnalyzer("baz", new FakeAnalyzer("search_quote"))); FieldMapper fieldMapper1 = new FakeFieldMapper("field1", fieldType1); FakeFieldType fieldType2 = new FakeFieldType(); - fieldType2.setNames(new MappedFieldType.Names("field2")); + fieldType2.setName("field2"); FieldMapper fieldMapper2 = new FakeFieldMapper("field2", fieldType2); Analyzer defaultIndex = new FakeAnalyzer("default_index"); diff --git a/core/src/test/java/org/elasticsearch/index/mapper/FieldTypeLookupTests.java b/core/src/test/java/org/elasticsearch/index/mapper/FieldTypeLookupTests.java index 8452c836041..c5dbd653bfe 100644 --- a/core/src/test/java/org/elasticsearch/index/mapper/FieldTypeLookupTests.java +++ b/core/src/test/java/org/elasticsearch/index/mapper/FieldTypeLookupTests.java @@ -38,15 +38,10 @@ public class FieldTypeLookupTests extends ESTestCase { public void testEmpty() { FieldTypeLookup lookup = new FieldTypeLookup(); assertNull(lookup.get("foo")); - assertNull(lookup.getByIndexName("foo")); assertEquals(Collections.emptySet(), lookup.getTypes("foo")); - assertEquals(Collections.emptySet(), lookup.getTypesByIndexName("foo")); Collection names = lookup.simpleMatchToFullName("foo"); assertNotNull(names); assertTrue(names.isEmpty()); - names = lookup.simpleMatchToIndexNames("foo"); - assertNotNull(names); - assertTrue(names.isEmpty()); Iterator itr = lookup.iterator(); assertNotNull(itr); assertFalse(itr.hasNext()); @@ -64,55 +59,45 @@ public class FieldTypeLookupTests extends ESTestCase { public void testAddNewField() { FieldTypeLookup lookup = new FieldTypeLookup(); - FakeFieldMapper f = new FakeFieldMapper("foo", "bar"); + FakeFieldMapper f = new FakeFieldMapper("foo"); FieldTypeLookup lookup2 = lookup.copyAndAddAll("type", newList(f), randomBoolean()); assertNull(lookup.get("foo")); assertNull(lookup.get("bar")); - assertNull(lookup.getByIndexName("foo")); - assertNull(lookup.getByIndexName("bar")); assertEquals(f.fieldType(), lookup2.get("foo")); assertNull(lookup.get("bar")); - assertEquals(f.fieldType(), lookup2.getByIndexName("bar")); - assertNull(lookup.getByIndexName("foo")); assertEquals(Collections.emptySet(), lookup.getTypes("foo")); - assertEquals(Collections.emptySet(), lookup.getTypesByIndexName("foo")); assertEquals(Collections.emptySet(), lookup.getTypes("bar")); - assertEquals(Collections.emptySet(), lookup.getTypesByIndexName("bar")); assertEquals(Collections.singleton("type"), lookup2.getTypes("foo")); - assertEquals(Collections.emptySet(), lookup2.getTypesByIndexName("foo")); assertEquals(Collections.emptySet(), lookup2.getTypes("bar")); - assertEquals(Collections.singleton("type"), lookup2.getTypesByIndexName("bar")); assertEquals(1, size(lookup2.iterator())); } public void testAddExistingField() { - FakeFieldMapper f = new FakeFieldMapper("foo", "foo"); - FakeFieldMapper f2 = new FakeFieldMapper("foo", "foo"); + FakeFieldMapper f = new FakeFieldMapper("foo"); + FakeFieldMapper f2 = new FakeFieldMapper("foo"); FieldTypeLookup lookup = new FieldTypeLookup(); lookup = lookup.copyAndAddAll("type1", newList(f), randomBoolean()); FieldTypeLookup lookup2 = lookup.copyAndAddAll("type2", newList(f2), randomBoolean()); assertSame(f2.fieldType(), lookup2.get("foo")); - assertSame(f2.fieldType(), lookup2.getByIndexName("foo")); assertEquals(1, size(lookup2.iterator())); } public void testAddExistingIndexName() { - FakeFieldMapper f = new FakeFieldMapper("foo", "foo"); - FakeFieldMapper f2 = new FakeFieldMapper("bar", "foo"); + FakeFieldMapper f = new FakeFieldMapper("foo"); + FakeFieldMapper f2 = new FakeFieldMapper("bar"); FieldTypeLookup lookup = new FieldTypeLookup(); lookup = lookup.copyAndAddAll("type1", newList(f), randomBoolean()); FieldTypeLookup lookup2 = lookup.copyAndAddAll("type2", newList(f2), randomBoolean()); assertSame(f.fieldType(), lookup2.get("foo")); assertSame(f2.fieldType(), lookup2.get("bar")); - assertSame(f2.fieldType(), lookup2.getByIndexName("foo")); assertEquals(2, size(lookup2.iterator())); } public void testAddExistingFullName() { - FakeFieldMapper f = new FakeFieldMapper("foo", "foo"); - FakeFieldMapper f2 = new FakeFieldMapper("foo", "bar"); + FakeFieldMapper f = new FakeFieldMapper("foo"); + FakeFieldMapper f2 = new FakeFieldMapper("foo"); FieldTypeLookup lookup = new FieldTypeLookup(); try { lookup.copyAndAddAll("type2", newList(f2), randomBoolean()); @@ -121,33 +106,12 @@ public class FieldTypeLookupTests extends ESTestCase { } } - public void testAddExistingBridgeName() { - FakeFieldMapper f = new FakeFieldMapper("foo", "foo"); - FakeFieldMapper f2 = new FakeFieldMapper("bar", "bar"); - FieldTypeLookup lookup = new FieldTypeLookup(); - lookup = lookup.copyAndAddAll("type1", newList(f, f2), randomBoolean()); - - try { - FakeFieldMapper f3 = new FakeFieldMapper("foo", "bar"); - lookup.copyAndAddAll("type2", newList(f3), randomBoolean()); - } catch (IllegalStateException e) { - assertTrue(e.getMessage().contains("insane mappings")); - } - - try { - FakeFieldMapper f3 = new FakeFieldMapper("bar", "foo"); - lookup.copyAndAddAll("type2", newList(f3), randomBoolean()); - } catch (IllegalStateException e) { - assertTrue(e.getMessage().contains("insane mappings")); - } - } - public void testCheckCompatibilityMismatchedTypes() { - FieldMapper f1 = new FakeFieldMapper("foo", "bar"); + FieldMapper f1 = new FakeFieldMapper("foo"); FieldTypeLookup lookup = new FieldTypeLookup(); lookup = lookup.copyAndAddAll("type", newList(f1), randomBoolean()); - MappedFieldType ft2 = FakeFieldMapper.makeOtherFieldType("foo", "foo"); + MappedFieldType ft2 = FakeFieldMapper.makeOtherFieldType("foo"); FieldMapper f2 = new FakeFieldMapper("foo", ft2); try { lookup.copyAndAddAll("type2", newList(f2), false); @@ -165,11 +129,11 @@ public class FieldTypeLookupTests extends ESTestCase { } public void testCheckCompatibilityConflict() { - FieldMapper f1 = new FakeFieldMapper("foo", "bar"); + FieldMapper f1 = new FakeFieldMapper("foo"); FieldTypeLookup lookup = new FieldTypeLookup(); lookup = lookup.copyAndAddAll("type", newList(f1), randomBoolean()); - MappedFieldType ft2 = FakeFieldMapper.makeFieldType("foo", "bar"); + MappedFieldType ft2 = FakeFieldMapper.makeFieldType("foo"); ft2.setBoost(2.0f); FieldMapper f2 = new FakeFieldMapper("foo", ft2); try { @@ -182,7 +146,7 @@ public class FieldTypeLookupTests extends ESTestCase { lookup.copyAndAddAll("type", newList(f2), false); // boost is updateable, so ok since we are implicitly updating all types lookup.copyAndAddAll("type2", newList(f2), true); // boost is updateable, so ok if forcing // now with a non changeable setting - MappedFieldType ft3 = FakeFieldMapper.makeFieldType("foo", "bar"); + MappedFieldType ft3 = FakeFieldMapper.makeFieldType("foo"); ft3.setStored(true); FieldMapper f3 = new FakeFieldMapper("foo", ft3); try { @@ -200,28 +164,18 @@ public class FieldTypeLookupTests extends ESTestCase { } } - public void testSimpleMatchIndexNames() { - FakeFieldMapper f1 = new FakeFieldMapper("foo", "baz"); - FakeFieldMapper f2 = new FakeFieldMapper("bar", "boo"); - FieldTypeLookup lookup = new FieldTypeLookup(); - lookup = lookup.copyAndAddAll("type", newList(f1, f2), randomBoolean()); - Collection names = lookup.simpleMatchToIndexNames("b*"); - assertTrue(names.contains("baz")); - assertTrue(names.contains("boo")); - } - public void testSimpleMatchFullNames() { - FakeFieldMapper f1 = new FakeFieldMapper("foo", "baz"); - FakeFieldMapper f2 = new FakeFieldMapper("bar", "boo"); + FakeFieldMapper f1 = new FakeFieldMapper("foo"); + FakeFieldMapper f2 = new FakeFieldMapper("bar"); FieldTypeLookup lookup = new FieldTypeLookup(); lookup = lookup.copyAndAddAll("type", newList(f1, f2), randomBoolean()); Collection names = lookup.simpleMatchToFullName("b*"); - assertTrue(names.contains("foo")); + assertFalse(names.contains("foo")); assertTrue(names.contains("bar")); } public void testIteratorImmutable() { - FakeFieldMapper f1 = new FakeFieldMapper("foo", "bar"); + FakeFieldMapper f1 = new FakeFieldMapper("foo"); FieldTypeLookup lookup = new FieldTypeLookup(); lookup = lookup.copyAndAddAll("type", newList(f1), randomBoolean()); @@ -243,20 +197,20 @@ public class FieldTypeLookupTests extends ESTestCase { // this sucks how much must be overridden just do get a dummy field mapper... static class FakeFieldMapper extends FieldMapper { static Settings dummySettings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT.id).build(); - public FakeFieldMapper(String fullName, String indexName) { - super(fullName, makeFieldType(fullName, indexName), makeFieldType(fullName, indexName), dummySettings, null, null); + public FakeFieldMapper(String fullName) { + super(fullName, makeFieldType(fullName), makeFieldType(fullName), dummySettings, null, null); } public FakeFieldMapper(String fullName, MappedFieldType fieldType) { super(fullName, fieldType, fieldType, dummySettings, null, null); } - static MappedFieldType makeFieldType(String fullName, String indexName) { + static MappedFieldType makeFieldType(String fullName) { FakeFieldType fieldType = new FakeFieldType(); - fieldType.setNames(new MappedFieldType.Names(indexName, indexName, fullName)); + fieldType.setName(fullName); return fieldType; } - static MappedFieldType makeOtherFieldType(String fullName, String indexName) { + static MappedFieldType makeOtherFieldType(String fullName) { OtherFakeFieldType fieldType = new OtherFakeFieldType(); - fieldType.setNames(new MappedFieldType.Names(indexName, indexName, fullName)); + fieldType.setName(fullName); return fieldType; } static class FakeFieldType extends MappedFieldType { diff --git a/core/src/test/java/org/elasticsearch/index/mapper/FieldTypeTestCase.java b/core/src/test/java/org/elasticsearch/index/mapper/FieldTypeTestCase.java index ca0cbf194d6..c8d7e4ac147 100644 --- a/core/src/test/java/org/elasticsearch/index/mapper/FieldTypeTestCase.java +++ b/core/src/test/java/org/elasticsearch/index/mapper/FieldTypeTestCase.java @@ -173,7 +173,7 @@ public abstract class FieldTypeTestCase extends ESTestCase { MappedFieldType createNamedDefaultFieldType() { MappedFieldType fieldType = createDefaultFieldType(); - fieldType.setNames(new MappedFieldType.Names("foo")); + fieldType.setName("foo"); return fieldType; } @@ -213,7 +213,7 @@ public abstract class FieldTypeTestCase extends ESTestCase { protected String toString(MappedFieldType ft) { return "MappedFieldType{" + - "names=" + ft.names() + + "name=" + ft.name() + ", boost=" + ft.boost() + ", docValues=" + ft.hasDocValues() + ", indexAnalyzer=" + ft.indexAnalyzer() + diff --git a/core/src/test/java/org/elasticsearch/index/mapper/completion/CompletionFieldMapperTests.java b/core/src/test/java/org/elasticsearch/index/mapper/completion/CompletionFieldMapperTests.java index 5422d6c2f7d..6de07d8cd0f 100644 --- a/core/src/test/java/org/elasticsearch/index/mapper/completion/CompletionFieldMapperTests.java +++ b/core/src/test/java/org/elasticsearch/index/mapper/completion/CompletionFieldMapperTests.java @@ -162,7 +162,7 @@ public class CompletionFieldMapperTests extends ESSingleNodeTestCase { .field("completion", "suggestion") .endObject() .bytes()); - IndexableField[] fields = parsedDocument.rootDoc().getFields(completionFieldType.names().indexName()); + IndexableField[] fields = parsedDocument.rootDoc().getFields(completionFieldType.name()); assertSuggestFields(fields, 1); } @@ -181,7 +181,7 @@ public class CompletionFieldMapperTests extends ESSingleNodeTestCase { .array("completion", "suggestion1", "suggestion2") .endObject() .bytes()); - IndexableField[] fields = parsedDocument.rootDoc().getFields(completionFieldType.names().indexName()); + IndexableField[] fields = parsedDocument.rootDoc().getFields(completionFieldType.name()); assertSuggestFields(fields, 2); } @@ -203,7 +203,7 @@ public class CompletionFieldMapperTests extends ESSingleNodeTestCase { .endObject() .endObject() .bytes()); - IndexableField[] fields = parsedDocument.rootDoc().getFields(completionFieldType.names().indexName()); + IndexableField[] fields = parsedDocument.rootDoc().getFields(completionFieldType.name()); assertSuggestFields(fields, 1); } @@ -225,7 +225,7 @@ public class CompletionFieldMapperTests extends ESSingleNodeTestCase { .endObject() .endObject() .bytes()); - IndexableField[] fields = parsedDocument.rootDoc().getFields(completionFieldType.names().indexName()); + IndexableField[] fields = parsedDocument.rootDoc().getFields(completionFieldType.name()); assertSuggestFields(fields, 3); } @@ -257,7 +257,7 @@ public class CompletionFieldMapperTests extends ESSingleNodeTestCase { .endArray() .endObject() .bytes()); - IndexableField[] fields = parsedDocument.rootDoc().getFields(completionFieldType.names().indexName()); + IndexableField[] fields = parsedDocument.rootDoc().getFields(completionFieldType.name()); assertSuggestFields(fields, 3); } @@ -289,7 +289,7 @@ public class CompletionFieldMapperTests extends ESSingleNodeTestCase { .endArray() .endObject() .bytes()); - IndexableField[] fields = parsedDocument.rootDoc().getFields(completionFieldType.names().indexName()); + IndexableField[] fields = parsedDocument.rootDoc().getFields(completionFieldType.name()); assertSuggestFields(fields, 6); } diff --git a/core/src/test/java/org/elasticsearch/index/mapper/externalvalues/ExternalMetadataMapper.java b/core/src/test/java/org/elasticsearch/index/mapper/externalvalues/ExternalMetadataMapper.java index 6ff0a428f79..9223b640024 100644 --- a/core/src/test/java/org/elasticsearch/index/mapper/externalvalues/ExternalMetadataMapper.java +++ b/core/src/test/java/org/elasticsearch/index/mapper/externalvalues/ExternalMetadataMapper.java @@ -45,7 +45,7 @@ public class ExternalMetadataMapper extends MetadataFieldMapper { private static MappedFieldType FIELD_TYPE = new BooleanFieldMapper.BooleanFieldType(); static { - FIELD_TYPE.setNames(new MappedFieldType.Names(FIELD_NAME)); + FIELD_TYPE.setName(FIELD_NAME); FIELD_TYPE.freeze(); } diff --git a/core/src/test/java/org/elasticsearch/index/mapper/internal/FieldNamesFieldMapperTests.java b/core/src/test/java/org/elasticsearch/index/mapper/internal/FieldNamesFieldMapperTests.java index e05bc21ba89..c15ebae636d 100644 --- a/core/src/test/java/org/elasticsearch/index/mapper/internal/FieldNamesFieldMapperTests.java +++ b/core/src/test/java/org/elasticsearch/index/mapper/internal/FieldNamesFieldMapperTests.java @@ -244,7 +244,7 @@ public class FieldNamesFieldMapperTests extends ESSingleNodeTestCase { static { FIELD_TYPE.setTokenized(false); FIELD_TYPE.setIndexOptions(IndexOptions.DOCS); - FIELD_TYPE.setNames(new MappedFieldType.Names("_dummy")); + FIELD_TYPE.setName("_dummy"); FIELD_TYPE.freeze(); } diff --git a/core/src/test/java/org/elasticsearch/index/mapper/internal/ParentFieldMapperTests.java b/core/src/test/java/org/elasticsearch/index/mapper/internal/ParentFieldMapperTests.java index 879c6590751..0d52b66dfb6 100644 --- a/core/src/test/java/org/elasticsearch/index/mapper/internal/ParentFieldMapperTests.java +++ b/core/src/test/java/org/elasticsearch/index/mapper/internal/ParentFieldMapperTests.java @@ -42,12 +42,12 @@ public class ParentFieldMapperTests extends ESTestCase { ParentFieldMapper parentFieldMapper = builder.build(new Mapper.BuilderContext(post2Dot0IndexSettings(), new ContentPath(0))); - assertThat(parentFieldMapper.getParentJoinFieldType().names().indexName(), equalTo("_parent#child")); + assertThat(parentFieldMapper.getParentJoinFieldType().name(), equalTo("_parent#child")); assertThat(parentFieldMapper.getParentJoinFieldType().fieldDataType(), nullValue()); assertThat(parentFieldMapper.getParentJoinFieldType().hasDocValues(), is(true)); assertThat(parentFieldMapper.getParentJoinFieldType().docValuesType(), equalTo(DocValuesType.SORTED)); - assertThat(parentFieldMapper.getChildJoinFieldType().names().indexName(), equalTo("_parent#parent")); + assertThat(parentFieldMapper.getChildJoinFieldType().name(), equalTo("_parent#parent")); assertThat(parentFieldMapper.getChildJoinFieldType().fieldDataType().getLoading(), equalTo(Loading.LAZY)); assertThat(parentFieldMapper.getChildJoinFieldType().hasDocValues(), is(true)); assertThat(parentFieldMapper.getChildJoinFieldType().docValuesType(), equalTo(DocValuesType.SORTED)); @@ -60,12 +60,12 @@ public class ParentFieldMapperTests extends ESTestCase { ParentFieldMapper parentFieldMapper = builder.build(new Mapper.BuilderContext(post2Dot0IndexSettings(), new ContentPath(0))); - assertThat(parentFieldMapper.getParentJoinFieldType().names().indexName(), equalTo("_parent#child")); + assertThat(parentFieldMapper.getParentJoinFieldType().name(), equalTo("_parent#child")); assertThat(parentFieldMapper.getParentJoinFieldType().fieldDataType(), nullValue()); assertThat(parentFieldMapper.getParentJoinFieldType().hasDocValues(), is(true)); assertThat(parentFieldMapper.getParentJoinFieldType().docValuesType(), equalTo(DocValuesType.SORTED)); - assertThat(parentFieldMapper.getChildJoinFieldType().names().indexName(), equalTo("_parent#parent")); + assertThat(parentFieldMapper.getChildJoinFieldType().name(), equalTo("_parent#parent")); assertThat(parentFieldMapper.getChildJoinFieldType().fieldDataType().getLoading(), equalTo(Loading.EAGER)); assertThat(parentFieldMapper.getChildJoinFieldType().hasDocValues(), is(true)); assertThat(parentFieldMapper.getChildJoinFieldType().docValuesType(), equalTo(DocValuesType.SORTED)); @@ -78,12 +78,12 @@ public class ParentFieldMapperTests extends ESTestCase { ParentFieldMapper parentFieldMapper = builder.build(new Mapper.BuilderContext(post2Dot0IndexSettings(), new ContentPath(0))); - assertThat(parentFieldMapper.getParentJoinFieldType().names().indexName(), equalTo("_parent#child")); + assertThat(parentFieldMapper.getParentJoinFieldType().name(), equalTo("_parent#child")); assertThat(parentFieldMapper.getParentJoinFieldType().fieldDataType(), nullValue()); assertThat(parentFieldMapper.getParentJoinFieldType().hasDocValues(), is(true)); assertThat(parentFieldMapper.getParentJoinFieldType().docValuesType(), equalTo(DocValuesType.SORTED)); - assertThat(parentFieldMapper.getChildJoinFieldType().names().indexName(), equalTo("_parent#parent")); + assertThat(parentFieldMapper.getChildJoinFieldType().name(), equalTo("_parent#parent")); assertThat(parentFieldMapper.getChildJoinFieldType().fieldDataType().getLoading(), equalTo(Loading.EAGER_GLOBAL_ORDINALS)); assertThat(parentFieldMapper.getChildJoinFieldType().hasDocValues(), is(true)); assertThat(parentFieldMapper.getChildJoinFieldType().docValuesType(), equalTo(DocValuesType.SORTED)); diff --git a/core/src/test/java/org/elasticsearch/index/mapper/simple/SimpleMapperTests.java b/core/src/test/java/org/elasticsearch/index/mapper/simple/SimpleMapperTests.java index 230af8d3a50..ed9792fb44e 100644 --- a/core/src/test/java/org/elasticsearch/index/mapper/simple/SimpleMapperTests.java +++ b/core/src/test/java/org/elasticsearch/index/mapper/simple/SimpleMapperTests.java @@ -55,7 +55,7 @@ public class SimpleMapperTests extends ESSingleNodeTestCase { BytesReference json = new BytesArray(copyToBytesFromClasspath("/org/elasticsearch/index/mapper/simple/test1.json")); Document doc = docMapper.parse("test", "person", "1", json).rootDoc(); - assertThat(doc.get(docMapper.mappers().getMapper("name.first").fieldType().names().indexName()), equalTo("shay")); + assertThat(doc.get(docMapper.mappers().getMapper("name.first").fieldType().name()), equalTo("shay")); doc = docMapper.parse("test", "person", "1", json).rootDoc(); } @@ -68,8 +68,8 @@ public class SimpleMapperTests extends ESSingleNodeTestCase { DocumentMapper builtDocMapper = parser.parse("person", new CompressedXContent(builtMapping)); BytesReference json = new BytesArray(copyToBytesFromClasspath("/org/elasticsearch/index/mapper/simple/test1.json")); Document doc = builtDocMapper.parse("test", "person", "1", json).rootDoc(); - assertThat(doc.get(docMapper.uidMapper().fieldType().names().indexName()), equalTo(Uid.createUid("person", "1"))); - assertThat(doc.get(docMapper.mappers().getMapper("name.first").fieldType().names().indexName()), equalTo("shay")); + assertThat(doc.get(docMapper.uidMapper().fieldType().name()), equalTo(Uid.createUid("person", "1"))); + assertThat(doc.get(docMapper.mappers().getMapper("name.first").fieldType().name()), equalTo("shay")); } public void testSimpleParser() throws Exception { @@ -80,8 +80,8 @@ public class SimpleMapperTests extends ESSingleNodeTestCase { BytesReference json = new BytesArray(copyToBytesFromClasspath("/org/elasticsearch/index/mapper/simple/test1.json")); Document doc = docMapper.parse("test", "person", "1", json).rootDoc(); - assertThat(doc.get(docMapper.uidMapper().fieldType().names().indexName()), equalTo(Uid.createUid("person", "1"))); - assertThat(doc.get(docMapper.mappers().getMapper("name.first").fieldType().names().indexName()), equalTo("shay")); + assertThat(doc.get(docMapper.uidMapper().fieldType().name()), equalTo(Uid.createUid("person", "1"))); + assertThat(doc.get(docMapper.mappers().getMapper("name.first").fieldType().name()), equalTo("shay")); } public void testSimpleParserNoTypeNoId() throws Exception { @@ -89,8 +89,8 @@ public class SimpleMapperTests extends ESSingleNodeTestCase { DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("person", new CompressedXContent(mapping)); BytesReference json = new BytesArray(copyToBytesFromClasspath("/org/elasticsearch/index/mapper/simple/test1-notype-noid.json")); Document doc = docMapper.parse("test", "person", "1", json).rootDoc(); - assertThat(doc.get(docMapper.uidMapper().fieldType().names().indexName()), equalTo(Uid.createUid("person", "1"))); - assertThat(doc.get(docMapper.mappers().getMapper("name.first").fieldType().names().indexName()), equalTo("shay")); + assertThat(doc.get(docMapper.uidMapper().fieldType().name()), equalTo(Uid.createUid("person", "1"))); + assertThat(doc.get(docMapper.mappers().getMapper("name.first").fieldType().name()), equalTo("shay")); } public void testAttributes() throws Exception { diff --git a/core/src/test/java/org/elasticsearch/index/query/FieldMaskingSpanQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/FieldMaskingSpanQueryBuilderTests.java index c0ffcfde361..f46f2982091 100644 --- a/core/src/test/java/org/elasticsearch/index/query/FieldMaskingSpanQueryBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/FieldMaskingSpanQueryBuilderTests.java @@ -46,7 +46,7 @@ public class FieldMaskingSpanQueryBuilderTests extends AbstractQueryTestCase { @Override - public MappedFieldType.Names getFieldNames() { - return new MappedFieldType.Names("test"); + public String getFieldName() { + return "test"; } @Override @@ -171,8 +170,8 @@ public class FunctionScoreTests extends ESTestCase { } @Override - public MappedFieldType.Names getFieldNames() { - return new MappedFieldType.Names("test"); + public String getFieldName() { + return "test"; } @Override diff --git a/core/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java b/core/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java index d749ba56594..64ec036ea1a 100644 --- a/core/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java +++ b/core/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java @@ -984,7 +984,7 @@ public class IndexShardTests extends ESSingleNodeTestCase { IndexShard newShard = reinitWithWrapper(indexService, shard, wrapper); try { // test global ordinals are evicted - MappedFieldType foo = newShard.mapperService().indexName("foo"); + MappedFieldType foo = newShard.mapperService().fullName("foo"); IndexFieldData.Global ifd = shard.indexFieldDataService().getForField(foo); FieldDataStats before = shard.fieldData().stats("foo"); assertThat(before.getMemorySizeInBytes(), equalTo(0l)); diff --git a/core/src/test/java/org/elasticsearch/search/suggest/completion/CategoryContextMappingTests.java b/core/src/test/java/org/elasticsearch/search/suggest/completion/CategoryContextMappingTests.java index 1dc7d20c7b7..0d27ba04a91 100644 --- a/core/src/test/java/org/elasticsearch/search/suggest/completion/CategoryContextMappingTests.java +++ b/core/src/test/java/org/elasticsearch/search/suggest/completion/CategoryContextMappingTests.java @@ -80,7 +80,7 @@ public class CategoryContextMappingTests extends ESSingleNodeTestCase { .endArray() .endObject() .bytes()); - IndexableField[] fields = parsedDocument.rootDoc().getFields(completionFieldType.names().indexName()); + IndexableField[] fields = parsedDocument.rootDoc().getFields(completionFieldType.name()); assertContextSuggestFields(fields, 7); } @@ -113,7 +113,7 @@ public class CategoryContextMappingTests extends ESSingleNodeTestCase { .endArray() .endObject() .bytes()); - IndexableField[] fields = parsedDocument.rootDoc().getFields(completionFieldType.names().indexName()); + IndexableField[] fields = parsedDocument.rootDoc().getFields(completionFieldType.name()); assertContextSuggestFields(fields, 3); } @@ -144,7 +144,7 @@ public class CategoryContextMappingTests extends ESSingleNodeTestCase { .endObject() .endObject() .bytes()); - IndexableField[] fields = parsedDocument.rootDoc().getFields(completionFieldType.names().indexName()); + IndexableField[] fields = parsedDocument.rootDoc().getFields(completionFieldType.name()); assertContextSuggestFields(fields, 3); } @@ -182,7 +182,7 @@ public class CategoryContextMappingTests extends ESSingleNodeTestCase { .endArray() .endObject(); ParsedDocument parsedDocument = defaultMapper.parse("test", "type1", "1", builder.bytes()); - IndexableField[] fields = parsedDocument.rootDoc().getFields(completionFieldType.names().indexName()); + IndexableField[] fields = parsedDocument.rootDoc().getFields(completionFieldType.name()); assertContextSuggestFields(fields, 3); } diff --git a/core/src/test/java/org/elasticsearch/search/suggest/completion/GeoContextMappingTests.java b/core/src/test/java/org/elasticsearch/search/suggest/completion/GeoContextMappingTests.java index 9e5dd86fea6..b42af82433b 100644 --- a/core/src/test/java/org/elasticsearch/search/suggest/completion/GeoContextMappingTests.java +++ b/core/src/test/java/org/elasticsearch/search/suggest/completion/GeoContextMappingTests.java @@ -80,7 +80,7 @@ public class GeoContextMappingTests extends ESSingleNodeTestCase { .endArray() .endObject() .bytes()); - IndexableField[] fields = parsedDocument.rootDoc().getFields(completionFieldType.names().indexName()); + IndexableField[] fields = parsedDocument.rootDoc().getFields(completionFieldType.name()); assertContextSuggestFields(fields, 7); } @@ -117,7 +117,7 @@ public class GeoContextMappingTests extends ESSingleNodeTestCase { .endArray() .endObject() .bytes()); - IndexableField[] fields = parsedDocument.rootDoc().getFields(completionFieldType.names().indexName()); + IndexableField[] fields = parsedDocument.rootDoc().getFields(completionFieldType.name()); assertContextSuggestFields(fields, 3); } @@ -156,7 +156,7 @@ public class GeoContextMappingTests extends ESSingleNodeTestCase { .field("weight", 5) .endObject() .bytes()); - IndexableField[] fields = parsedDocument.rootDoc().getFields(completionFieldType.names().indexName()); + IndexableField[] fields = parsedDocument.rootDoc().getFields(completionFieldType.name()); assertContextSuggestFields(fields, 3); } @@ -194,7 +194,7 @@ public class GeoContextMappingTests extends ESSingleNodeTestCase { .endArray() .endObject(); ParsedDocument parsedDocument = defaultMapper.parse("test", "type1", "1", builder.bytes()); - IndexableField[] fields = parsedDocument.rootDoc().getFields(completionFieldType.names().indexName()); + IndexableField[] fields = parsedDocument.rootDoc().getFields(completionFieldType.name()); assertContextSuggestFields(fields, 3); } diff --git a/modules/lang-expression/src/main/java/org/elasticsearch/script/expression/CountMethodValueSource.java b/modules/lang-expression/src/main/java/org/elasticsearch/script/expression/CountMethodValueSource.java index a92e8d9dd38..c50aa4da289 100644 --- a/modules/lang-expression/src/main/java/org/elasticsearch/script/expression/CountMethodValueSource.java +++ b/modules/lang-expression/src/main/java/org/elasticsearch/script/expression/CountMethodValueSource.java @@ -67,6 +67,6 @@ public class CountMethodValueSource extends ValueSource { @Override public String description() { - return "count: field(" + fieldData.getFieldNames().toString() + ")"; + return "count: field(" + fieldData.getFieldName() + ")"; } } diff --git a/modules/lang-expression/src/main/java/org/elasticsearch/script/expression/DateMethodValueSource.java b/modules/lang-expression/src/main/java/org/elasticsearch/script/expression/DateMethodValueSource.java index 8bbf6251fc3..9efeed54ff9 100644 --- a/modules/lang-expression/src/main/java/org/elasticsearch/script/expression/DateMethodValueSource.java +++ b/modules/lang-expression/src/main/java/org/elasticsearch/script/expression/DateMethodValueSource.java @@ -54,7 +54,7 @@ class DateMethodValueSource extends FieldDataValueSource { @Override public String description() { - return methodName + ": field(" + fieldData.getFieldNames().toString() + ")"; + return methodName + ": field(" + fieldData.getFieldName() + ")"; } @Override diff --git a/modules/lang-expression/src/main/java/org/elasticsearch/script/expression/ExpressionScriptEngineService.java b/modules/lang-expression/src/main/java/org/elasticsearch/script/expression/ExpressionScriptEngineService.java index cf6017a32ca..192f69884e8 100644 --- a/modules/lang-expression/src/main/java/org/elasticsearch/script/expression/ExpressionScriptEngineService.java +++ b/modules/lang-expression/src/main/java/org/elasticsearch/script/expression/ExpressionScriptEngineService.java @@ -184,7 +184,7 @@ public class ExpressionScriptEngineService extends AbstractComponent implements throw new ScriptException("Variable [" + variable + "] does not follow an allowed format of either doc['field'] or doc['field'].method()"); } - MappedFieldType fieldType = mapper.smartNameFieldType(fieldname); + MappedFieldType fieldType = mapper.fullName(fieldname); if (fieldType == null) { throw new ScriptException("Field [" + fieldname + "] used in expression does not exist in mappings"); diff --git a/modules/lang-expression/src/main/java/org/elasticsearch/script/expression/FieldDataValueSource.java b/modules/lang-expression/src/main/java/org/elasticsearch/script/expression/FieldDataValueSource.java index 39386ee4913..708cd0af152 100644 --- a/modules/lang-expression/src/main/java/org/elasticsearch/script/expression/FieldDataValueSource.java +++ b/modules/lang-expression/src/main/java/org/elasticsearch/script/expression/FieldDataValueSource.java @@ -75,6 +75,6 @@ class FieldDataValueSource extends ValueSource { @Override public String description() { - return "field(" + fieldData.getFieldNames().toString() + ")"; + return "field(" + fieldData.getFieldName() + ")"; } } diff --git a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/GeoShapeIntegrationTests.java b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/GeoShapeIntegrationTests.java index 37132c5a923..98a23b3e1fd 100644 --- a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/GeoShapeIntegrationTests.java +++ b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/GeoShapeIntegrationTests.java @@ -77,7 +77,7 @@ public class GeoShapeIntegrationTests extends ESIntegTestCase { // left orientation test IndicesService indicesService = internalCluster().getInstance(IndicesService.class, findNodeName(idxName)); IndexService indexService = indicesService.indexService(idxName); - MappedFieldType fieldType = indexService.mapperService().smartNameFieldType("location"); + MappedFieldType fieldType = indexService.mapperService().fullName("location"); assertThat(fieldType, instanceOf(GeoShapeFieldMapper.GeoShapeFieldType.class)); GeoShapeFieldMapper.GeoShapeFieldType gsfm = (GeoShapeFieldMapper.GeoShapeFieldType)fieldType; @@ -89,7 +89,7 @@ public class GeoShapeIntegrationTests extends ESIntegTestCase { // right orientation test indicesService = internalCluster().getInstance(IndicesService.class, findNodeName(idxName+"2")); indexService = indicesService.indexService(idxName+"2"); - fieldType = indexService.mapperService().smartNameFieldType("location"); + fieldType = indexService.mapperService().fullName("location"); assertThat(fieldType, instanceOf(GeoShapeFieldMapper.GeoShapeFieldType.class)); gsfm = (GeoShapeFieldMapper.GeoShapeFieldType)fieldType; diff --git a/plugins/mapper-attachments/src/test/java/org/elasticsearch/mapper/attachments/EncryptedDocMapperTests.java b/plugins/mapper-attachments/src/test/java/org/elasticsearch/mapper/attachments/EncryptedDocMapperTests.java index f550193b847..21627daeb53 100644 --- a/plugins/mapper-attachments/src/test/java/org/elasticsearch/mapper/attachments/EncryptedDocMapperTests.java +++ b/plugins/mapper-attachments/src/test/java/org/elasticsearch/mapper/attachments/EncryptedDocMapperTests.java @@ -61,19 +61,19 @@ public class EncryptedDocMapperTests extends AttachmentUnitTestCase { .endObject().bytes(); ParseContext.Document doc = docMapper.parse("person", "person", "1", json).rootDoc(); - assertThat(doc.get(docMapper.mappers().getMapper("file1.content").fieldType().names().indexName()), containsString("World")); - assertThat(doc.get(docMapper.mappers().getMapper("file1.title").fieldType().names().indexName()), equalTo("Hello")); - assertThat(doc.get(docMapper.mappers().getMapper("file1.author").fieldType().names().indexName()), equalTo("kimchy")); - assertThat(doc.get(docMapper.mappers().getMapper("file1.keywords").fieldType().names().indexName()), equalTo("elasticsearch,cool,bonsai")); - assertThat(doc.get(docMapper.mappers().getMapper("file1.content_type").fieldType().names().indexName()), startsWith("text/html;")); - assertThat(doc.getField(docMapper.mappers().getMapper("file1.content_length").fieldType().names().indexName()).numericValue().longValue(), greaterThan(0L)); + assertThat(doc.get(docMapper.mappers().getMapper("file1.content").fieldType().name()), containsString("World")); + assertThat(doc.get(docMapper.mappers().getMapper("file1.title").fieldType().name()), equalTo("Hello")); + assertThat(doc.get(docMapper.mappers().getMapper("file1.author").fieldType().name()), equalTo("kimchy")); + assertThat(doc.get(docMapper.mappers().getMapper("file1.keywords").fieldType().name()), equalTo("elasticsearch,cool,bonsai")); + assertThat(doc.get(docMapper.mappers().getMapper("file1.content_type").fieldType().name()), startsWith("text/html;")); + assertThat(doc.getField(docMapper.mappers().getMapper("file1.content_length").fieldType().name()).numericValue().longValue(), greaterThan(0L)); - assertThat(doc.get(docMapper.mappers().getMapper("file2").fieldType().names().indexName()), nullValue()); - assertThat(doc.get(docMapper.mappers().getMapper("file2.title").fieldType().names().indexName()), nullValue()); - assertThat(doc.get(docMapper.mappers().getMapper("file2.author").fieldType().names().indexName()), nullValue()); - assertThat(doc.get(docMapper.mappers().getMapper("file2.keywords").fieldType().names().indexName()), nullValue()); - assertThat(doc.get(docMapper.mappers().getMapper("file2.content_type").fieldType().names().indexName()), nullValue()); - assertThat(doc.getField(docMapper.mappers().getMapper("file2.content_length").fieldType().names().indexName()), nullValue()); + assertThat(doc.get(docMapper.mappers().getMapper("file2").fieldType().name()), nullValue()); + assertThat(doc.get(docMapper.mappers().getMapper("file2.title").fieldType().name()), nullValue()); + assertThat(doc.get(docMapper.mappers().getMapper("file2.author").fieldType().name()), nullValue()); + assertThat(doc.get(docMapper.mappers().getMapper("file2.keywords").fieldType().name()), nullValue()); + assertThat(doc.get(docMapper.mappers().getMapper("file2.content_type").fieldType().name()), nullValue()); + assertThat(doc.getField(docMapper.mappers().getMapper("file2.content_length").fieldType().name()), nullValue()); } public void testMultipleDocsEncryptedFirst() throws IOException { @@ -90,19 +90,19 @@ public class EncryptedDocMapperTests extends AttachmentUnitTestCase { .endObject().bytes(); ParseContext.Document doc = docMapper.parse("person", "person", "1", json).rootDoc(); - assertThat(doc.get(docMapper.mappers().getMapper("file1").fieldType().names().indexName()), nullValue()); - assertThat(doc.get(docMapper.mappers().getMapper("file1.title").fieldType().names().indexName()), nullValue()); - assertThat(doc.get(docMapper.mappers().getMapper("file1.author").fieldType().names().indexName()), nullValue()); - assertThat(doc.get(docMapper.mappers().getMapper("file1.keywords").fieldType().names().indexName()), nullValue()); - assertThat(doc.get(docMapper.mappers().getMapper("file1.content_type").fieldType().names().indexName()), nullValue()); - assertThat(doc.getField(docMapper.mappers().getMapper("file1.content_length").fieldType().names().indexName()), nullValue()); + assertThat(doc.get(docMapper.mappers().getMapper("file1").fieldType().name()), nullValue()); + assertThat(doc.get(docMapper.mappers().getMapper("file1.title").fieldType().name()), nullValue()); + assertThat(doc.get(docMapper.mappers().getMapper("file1.author").fieldType().name()), nullValue()); + assertThat(doc.get(docMapper.mappers().getMapper("file1.keywords").fieldType().name()), nullValue()); + assertThat(doc.get(docMapper.mappers().getMapper("file1.content_type").fieldType().name()), nullValue()); + assertThat(doc.getField(docMapper.mappers().getMapper("file1.content_length").fieldType().name()), nullValue()); - assertThat(doc.get(docMapper.mappers().getMapper("file2.content").fieldType().names().indexName()), containsString("World")); - assertThat(doc.get(docMapper.mappers().getMapper("file2.title").fieldType().names().indexName()), equalTo("Hello")); - assertThat(doc.get(docMapper.mappers().getMapper("file2.author").fieldType().names().indexName()), equalTo("kimchy")); - assertThat(doc.get(docMapper.mappers().getMapper("file2.keywords").fieldType().names().indexName()), equalTo("elasticsearch,cool,bonsai")); - assertThat(doc.get(docMapper.mappers().getMapper("file2.content_type").fieldType().names().indexName()), startsWith("text/html;")); - assertThat(doc.getField(docMapper.mappers().getMapper("file2.content_length").fieldType().names().indexName()).numericValue().longValue(), greaterThan(0L)); + assertThat(doc.get(docMapper.mappers().getMapper("file2.content").fieldType().name()), containsString("World")); + assertThat(doc.get(docMapper.mappers().getMapper("file2.title").fieldType().name()), equalTo("Hello")); + assertThat(doc.get(docMapper.mappers().getMapper("file2.author").fieldType().name()), equalTo("kimchy")); + assertThat(doc.get(docMapper.mappers().getMapper("file2.keywords").fieldType().name()), equalTo("elasticsearch,cool,bonsai")); + assertThat(doc.get(docMapper.mappers().getMapper("file2.content_type").fieldType().name()), startsWith("text/html;")); + assertThat(doc.getField(docMapper.mappers().getMapper("file2.content_length").fieldType().name()).numericValue().longValue(), greaterThan(0L)); } public void testMultipleDocsEncryptedNotIgnoringErrors() throws IOException { diff --git a/plugins/mapper-attachments/src/test/java/org/elasticsearch/mapper/attachments/LanguageDetectionAttachmentMapperTests.java b/plugins/mapper-attachments/src/test/java/org/elasticsearch/mapper/attachments/LanguageDetectionAttachmentMapperTests.java index 190231eb95e..5d81df7a7fe 100644 --- a/plugins/mapper-attachments/src/test/java/org/elasticsearch/mapper/attachments/LanguageDetectionAttachmentMapperTests.java +++ b/plugins/mapper-attachments/src/test/java/org/elasticsearch/mapper/attachments/LanguageDetectionAttachmentMapperTests.java @@ -77,7 +77,7 @@ public class LanguageDetectionAttachmentMapperTests extends AttachmentUnitTestCa ParseContext.Document doc = docMapper.parse("person", "person", "1", xcb.bytes()).rootDoc(); // Our mapping should be kept as a String - assertThat(doc.get(docMapper.mappers().getMapper("file.language").fieldType().names().indexName()), equalTo(expected)); + assertThat(doc.get(docMapper.mappers().getMapper("file.language").fieldType().name()), equalTo(expected)); } public void testFrDetection() throws Exception { @@ -122,6 +122,6 @@ public class LanguageDetectionAttachmentMapperTests extends AttachmentUnitTestCa ParseContext.Document doc = docMapper.parse("person", "person", "1", xcb.bytes()).rootDoc(); // Our mapping should be kept as a String - assertThat(doc.get(docMapper.mappers().getMapper("file.language").fieldType().names().indexName()), equalTo("en")); + assertThat(doc.get(docMapper.mappers().getMapper("file.language").fieldType().name()), equalTo("en")); } } diff --git a/plugins/mapper-attachments/src/test/java/org/elasticsearch/mapper/attachments/MetadataMapperTests.java b/plugins/mapper-attachments/src/test/java/org/elasticsearch/mapper/attachments/MetadataMapperTests.java index 0a0f69edcfd..b44a6d55eb9 100644 --- a/plugins/mapper-attachments/src/test/java/org/elasticsearch/mapper/attachments/MetadataMapperTests.java +++ b/plugins/mapper-attachments/src/test/java/org/elasticsearch/mapper/attachments/MetadataMapperTests.java @@ -65,21 +65,21 @@ public class MetadataMapperTests extends AttachmentUnitTestCase { .endObject().bytes(); ParseContext.Document doc = docMapper.parse("person", "person", "1", json).rootDoc(); - assertThat(doc.get(docMapper.mappers().getMapper("file.content").fieldType().names().indexName()), containsString("World")); - assertThat(doc.get(docMapper.mappers().getMapper("file.name").fieldType().names().indexName()), equalTo(filename)); + assertThat(doc.get(docMapper.mappers().getMapper("file.content").fieldType().name()), containsString("World")); + assertThat(doc.get(docMapper.mappers().getMapper("file.name").fieldType().name()), equalTo(filename)); if (expectedDate == null) { - assertThat(doc.getField(docMapper.mappers().getMapper("file.date").fieldType().names().indexName()), nullValue()); + assertThat(doc.getField(docMapper.mappers().getMapper("file.date").fieldType().name()), nullValue()); } else { - assertThat(doc.getField(docMapper.mappers().getMapper("file.date").fieldType().names().indexName()).numericValue().longValue(), is(expectedDate)); + assertThat(doc.getField(docMapper.mappers().getMapper("file.date").fieldType().name()).numericValue().longValue(), is(expectedDate)); } - assertThat(doc.get(docMapper.mappers().getMapper("file.title").fieldType().names().indexName()), equalTo("Hello")); - assertThat(doc.get(docMapper.mappers().getMapper("file.author").fieldType().names().indexName()), equalTo("kimchy")); - assertThat(doc.get(docMapper.mappers().getMapper("file.keywords").fieldType().names().indexName()), equalTo("elasticsearch,cool,bonsai")); - assertThat(doc.get(docMapper.mappers().getMapper("file.content_type").fieldType().names().indexName()), startsWith("text/html;")); + assertThat(doc.get(docMapper.mappers().getMapper("file.title").fieldType().name()), equalTo("Hello")); + assertThat(doc.get(docMapper.mappers().getMapper("file.author").fieldType().name()), equalTo("kimchy")); + assertThat(doc.get(docMapper.mappers().getMapper("file.keywords").fieldType().name()), equalTo("elasticsearch,cool,bonsai")); + assertThat(doc.get(docMapper.mappers().getMapper("file.content_type").fieldType().name()), startsWith("text/html;")); if (expectedLength == null) { - assertNull(doc.getField(docMapper.mappers().getMapper("file.content_length").fieldType().names().indexName()).numericValue().longValue()); + assertNull(doc.getField(docMapper.mappers().getMapper("file.content_length").fieldType().name()).numericValue().longValue()); } else { - assertThat(doc.getField(docMapper.mappers().getMapper("file.content_length").fieldType().names().indexName()).numericValue().longValue(), greaterThan(0L)); + assertThat(doc.getField(docMapper.mappers().getMapper("file.content_length").fieldType().name()).numericValue().longValue(), greaterThan(0L)); } } diff --git a/plugins/mapper-attachments/src/test/java/org/elasticsearch/mapper/attachments/SimpleAttachmentMapperTests.java b/plugins/mapper-attachments/src/test/java/org/elasticsearch/mapper/attachments/SimpleAttachmentMapperTests.java index 7618c4de5a1..fd5f480700c 100644 --- a/plugins/mapper-attachments/src/test/java/org/elasticsearch/mapper/attachments/SimpleAttachmentMapperTests.java +++ b/plugins/mapper-attachments/src/test/java/org/elasticsearch/mapper/attachments/SimpleAttachmentMapperTests.java @@ -19,8 +19,6 @@ package org.elasticsearch.mapper.attachments; -import org.elasticsearch.Version; -import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.compress.CompressedXContent; import org.elasticsearch.common.settings.Settings; @@ -52,9 +50,9 @@ public class SimpleAttachmentMapperTests extends AttachmentUnitTestCase { BytesReference json = jsonBuilder().startObject().field("file", html).endObject().bytes(); ParseContext.Document doc = docMapper.parse("person", "person", "1", json).rootDoc(); - assertThat(doc.get(docMapper.mappers().getMapper("file.content_type").fieldType().names().indexName()), startsWith("application/xhtml+xml")); - assertThat(doc.get(docMapper.mappers().getMapper("file.title").fieldType().names().indexName()), equalTo("XHTML test document")); - assertThat(doc.get(docMapper.mappers().getMapper("file.content").fieldType().names().indexName()), containsString("This document tests the ability of Apache Tika to extract content")); + assertThat(doc.get(docMapper.mappers().getMapper("file.content_type").fieldType().name()), startsWith("application/xhtml+xml")); + assertThat(doc.get(docMapper.mappers().getMapper("file.title").fieldType().name()), equalTo("XHTML test document")); + assertThat(doc.get(docMapper.mappers().getMapper("file.content").fieldType().name()), containsString("This document tests the ability of Apache Tika to extract content")); // re-parse it String builtMapping = docMapper.mappingSource().string(); @@ -64,23 +62,9 @@ public class SimpleAttachmentMapperTests extends AttachmentUnitTestCase { doc = docMapper.parse("person", "person", "1", json).rootDoc(); - assertThat(doc.get(docMapper.mappers().getMapper("file.content_type").fieldType().names().indexName()), startsWith("application/xhtml+xml")); - assertThat(doc.get(docMapper.mappers().getMapper("file.title").fieldType().names().indexName()), equalTo("XHTML test document")); - assertThat(doc.get(docMapper.mappers().getMapper("file.content").fieldType().names().indexName()), containsString("This document tests the ability of Apache Tika to extract content")); - } - - public void testContentBackcompat() throws Exception { - DocumentMapperParser mapperParser = MapperTestUtils.newMapperService(createTempDir(), - Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_1_4_2.id).build(), - getIndicesModuleWithRegisteredAttachmentMapper()).documentMapperParser(); - String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/attachment/test/unit/simple/test-mapping.json"); - DocumentMapper docMapper = mapperParser.parse("person", new CompressedXContent(mapping)); - byte[] html = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/attachment/test/sample-files/testXHTML.html"); - - BytesReference json = jsonBuilder().startObject().field("file", html).endObject().bytes(); - - ParseContext.Document doc = docMapper.parse("person", "person", "1", json).rootDoc(); - assertThat(doc.get("file"), containsString("This document tests the ability of Apache Tika to extract content")); + assertThat(doc.get(docMapper.mappers().getMapper("file.content_type").fieldType().name()), startsWith("application/xhtml+xml")); + assertThat(doc.get(docMapper.mappers().getMapper("file.title").fieldType().name()), equalTo("XHTML test document")); + assertThat(doc.get(docMapper.mappers().getMapper("file.content").fieldType().name()), containsString("This document tests the ability of Apache Tika to extract content")); } /** @@ -95,9 +79,9 @@ public class SimpleAttachmentMapperTests extends AttachmentUnitTestCase { BytesReference json = jsonBuilder().startObject().field("file", html).endObject().bytes(); ParseContext.Document doc = docMapper.parse("person", "person", "1", json).rootDoc(); - assertThat(doc.get(docMapper.mappers().getMapper("file.content_type").fieldType().names().indexName()), startsWith("application/xhtml+xml")); - assertThat(doc.get(docMapper.mappers().getMapper("file.title").fieldType().names().indexName()), equalTo("XHTML test document")); - assertThat(doc.get(docMapper.mappers().getMapper("file.content").fieldType().names().indexName()), containsString("This document tests the ability of Apache Tika to extract content")); + assertThat(doc.get(docMapper.mappers().getMapper("file.content_type").fieldType().name()), startsWith("application/xhtml+xml")); + assertThat(doc.get(docMapper.mappers().getMapper("file.title").fieldType().name()), equalTo("XHTML test document")); + assertThat(doc.get(docMapper.mappers().getMapper("file.content").fieldType().name()), containsString("This document tests the ability of Apache Tika to extract content")); // re-parse it String builtMapping = docMapper.mappingSource().string(); @@ -107,9 +91,9 @@ public class SimpleAttachmentMapperTests extends AttachmentUnitTestCase { doc = docMapper.parse("person", "person", "1", json).rootDoc(); - assertThat(doc.get(docMapper.mappers().getMapper("file.content_type").fieldType().names().indexName()), startsWith("application/xhtml+xml")); - assertThat(doc.get(docMapper.mappers().getMapper("file.title").fieldType().names().indexName()), equalTo("XHTML test document")); - assertThat(doc.get(docMapper.mappers().getMapper("file.content").fieldType().names().indexName()), containsString("This document tests the ability of Apache Tika to extract content")); + assertThat(doc.get(docMapper.mappers().getMapper("file.content_type").fieldType().name()), startsWith("application/xhtml+xml")); + assertThat(doc.get(docMapper.mappers().getMapper("file.title").fieldType().name()), equalTo("XHTML test document")); + assertThat(doc.get(docMapper.mappers().getMapper("file.content").fieldType().name()), containsString("This document tests the ability of Apache Tika to extract content")); } /** diff --git a/plugins/mapper-attachments/src/test/java/org/elasticsearch/mapper/attachments/StandaloneRunner.java b/plugins/mapper-attachments/src/test/java/org/elasticsearch/mapper/attachments/StandaloneRunner.java index 137980c6b36..217d48a8565 100644 --- a/plugins/mapper-attachments/src/test/java/org/elasticsearch/mapper/attachments/StandaloneRunner.java +++ b/plugins/mapper-attachments/src/test/java/org/elasticsearch/mapper/attachments/StandaloneRunner.java @@ -135,7 +135,7 @@ public class StandaloneRunner extends CliTool { } private void printMetadataContent(ParseContext.Document doc, String field) { - terminal.println("- %s: %s", field, doc.get(docMapper.mappers().getMapper("file." + field).fieldType().names().indexName())); + terminal.println("- %s: %s", field, doc.get(docMapper.mappers().getMapper("file." + field).fieldType().name())); } public static byte[] copyToBytes(Path path) throws IOException { diff --git a/plugins/mapper-attachments/src/test/java/org/elasticsearch/mapper/attachments/VariousDocTests.java b/plugins/mapper-attachments/src/test/java/org/elasticsearch/mapper/attachments/VariousDocTests.java index 94beb54d281..9475c85a5f4 100644 --- a/plugins/mapper-attachments/src/test/java/org/elasticsearch/mapper/attachments/VariousDocTests.java +++ b/plugins/mapper-attachments/src/test/java/org/elasticsearch/mapper/attachments/VariousDocTests.java @@ -156,8 +156,8 @@ public class VariousDocTests extends AttachmentUnitTestCase { ParseContext.Document doc = docMapper.parse("person", "person", "1", json).rootDoc(); if (!errorExpected) { - assertThat(doc.get(docMapper.mappers().getMapper("file.content").fieldType().names().indexName()), not(isEmptyOrNullString())); - logger.debug("-> extracted content: {}", doc.get(docMapper.mappers().getMapper("file").fieldType().names().indexName())); + assertThat(doc.get(docMapper.mappers().getMapper("file.content").fieldType().name()), not(isEmptyOrNullString())); + logger.debug("-> extracted content: {}", doc.get(docMapper.mappers().getMapper("file").fieldType().name())); logger.debug("-> extracted metadata:"); printMetadataContent(doc, AUTHOR); printMetadataContent(doc, CONTENT_LENGTH); @@ -171,6 +171,6 @@ public class VariousDocTests extends AttachmentUnitTestCase { } private void printMetadataContent(ParseContext.Document doc, String field) { - logger.debug("- [{}]: [{}]", field, doc.get(docMapper.mappers().getMapper("file." + field).fieldType().names().indexName())); + logger.debug("- [{}]: [{}]", field, doc.get(docMapper.mappers().getMapper("file." + field).fieldType().name())); } } diff --git a/plugins/mapper-size/src/main/java/org/elasticsearch/index/mapper/size/SizeFieldMapper.java b/plugins/mapper-size/src/main/java/org/elasticsearch/index/mapper/size/SizeFieldMapper.java index 1e27e18bac7..3fa9f1ffe1e 100644 --- a/plugins/mapper-size/src/main/java/org/elasticsearch/index/mapper/size/SizeFieldMapper.java +++ b/plugins/mapper-size/src/main/java/org/elasticsearch/index/mapper/size/SizeFieldMapper.java @@ -54,7 +54,7 @@ public class SizeFieldMapper extends MetadataFieldMapper { static { SIZE_FIELD_TYPE.setStored(true); SIZE_FIELD_TYPE.setNumericPrecisionStep(Defaults.PRECISION_STEP_32_BIT); - SIZE_FIELD_TYPE.setNames(new MappedFieldType.Names(NAME)); + SIZE_FIELD_TYPE.setName(NAME); SIZE_FIELD_TYPE.setIndexAnalyzer(NumericIntegerAnalyzer.buildNamedAnalyzer(Defaults.PRECISION_STEP_32_BIT)); SIZE_FIELD_TYPE.setSearchAnalyzer(NumericIntegerAnalyzer.buildNamedAnalyzer(Integer.MAX_VALUE)); SIZE_FIELD_TYPE.freeze(); diff --git a/test/framework/src/main/java/org/elasticsearch/test/TestSearchContext.java b/test/framework/src/main/java/org/elasticsearch/test/TestSearchContext.java index 7fec7e8e4ac..796872bd350 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/TestSearchContext.java +++ b/test/framework/src/main/java/org/elasticsearch/test/TestSearchContext.java @@ -548,18 +548,11 @@ public class TestSearchContext extends SearchContext { return null; } + @Override public MappedFieldType smartNameFieldType(String name) { if (mapperService() != null) { - return mapperService().smartNameFieldType(name, types()); - } - return null; - } - - @Override - public MappedFieldType smartNameFieldTypeFromAnyType(String name) { - if (mapperService() != null) { - return mapperService().smartNameFieldType(name); + return mapperService().fullName(name); } return null; } @@ -567,7 +560,7 @@ public class TestSearchContext extends SearchContext { @Override public ObjectMapper getObjectMapper(String name) { if (mapperService() != null) { - return mapperService().getObjectMapper(name, types); + return mapperService().getObjectMapper(name); } return null; }