Rename Mapper#name to Mapper#leafName (#109971)

This addresses a long standing TODO that caused quite a few bugs over time, in that the mapper name does not include its full path, while
the MappedFieldType name does.
This commit is contained in:
Luca Cavanna 2024-06-21 11:48:17 +02:00 committed by GitHub
parent d79f18d069
commit 15c7abe111
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
49 changed files with 179 additions and 150 deletions

View file

@ -323,7 +323,7 @@ public class LegacyGeoShapeFieldMapper extends AbstractShapeGeometryFieldMapper<
private GeoShapeFieldType buildFieldType(LegacyGeoShapeParser parser, MapperBuilderContext context) { private GeoShapeFieldType buildFieldType(LegacyGeoShapeParser parser, MapperBuilderContext context) {
GeoShapeFieldType ft = new GeoShapeFieldType( GeoShapeFieldType ft = new GeoShapeFieldType(
context.buildFullName(name()), context.buildFullName(leafName()),
indexed.get(), indexed.get(),
orientation.get().value(), orientation.get().value(),
parser, parser,
@ -352,7 +352,7 @@ public class LegacyGeoShapeFieldMapper extends AbstractShapeGeometryFieldMapper<
public LegacyGeoShapeFieldMapper build(MapperBuilderContext context) { public LegacyGeoShapeFieldMapper build(MapperBuilderContext context) {
LegacyGeoShapeParser parser = new LegacyGeoShapeParser(); LegacyGeoShapeParser parser = new LegacyGeoShapeParser();
GeoShapeFieldType ft = buildFieldType(parser, context); GeoShapeFieldType ft = buildFieldType(parser, context);
return new LegacyGeoShapeFieldMapper(name(), ft, multiFieldsBuilder.build(this, context), copyTo, parser, this); return new LegacyGeoShapeFieldMapper(leafName(), ft, multiFieldsBuilder.build(this, context), copyTo, parser, this);
} }
} }

View file

@ -127,7 +127,7 @@ public class MatchOnlyTextFieldMapper extends FieldMapper {
NamedAnalyzer indexAnalyzer = analyzers.getIndexAnalyzer(); NamedAnalyzer indexAnalyzer = analyzers.getIndexAnalyzer();
TextSearchInfo tsi = new TextSearchInfo(Defaults.FIELD_TYPE, null, searchAnalyzer, searchQuoteAnalyzer); TextSearchInfo tsi = new TextSearchInfo(Defaults.FIELD_TYPE, null, searchAnalyzer, searchQuoteAnalyzer);
MatchOnlyTextFieldType ft = new MatchOnlyTextFieldType( MatchOnlyTextFieldType ft = new MatchOnlyTextFieldType(
context.buildFullName(name()), context.buildFullName(leafName()),
tsi, tsi,
indexAnalyzer, indexAnalyzer,
context.isSourceSynthetic(), context.isSourceSynthetic(),
@ -140,7 +140,15 @@ public class MatchOnlyTextFieldMapper extends FieldMapper {
public MatchOnlyTextFieldMapper build(MapperBuilderContext context) { public MatchOnlyTextFieldMapper build(MapperBuilderContext context) {
MatchOnlyTextFieldType tft = buildFieldType(context); MatchOnlyTextFieldType tft = buildFieldType(context);
MultiFields multiFields = multiFieldsBuilder.build(this, context); MultiFields multiFields = multiFieldsBuilder.build(this, context);
return new MatchOnlyTextFieldMapper(name(), Defaults.FIELD_TYPE, tft, multiFields, copyTo, context.isSourceSynthetic(), this); return new MatchOnlyTextFieldMapper(
leafName(),
Defaults.FIELD_TYPE,
tft,
multiFields,
copyTo,
context.isSourceSynthetic(),
this
);
} }
} }

View file

@ -91,9 +91,9 @@ public class RankFeatureFieldMapper extends FieldMapper {
@Override @Override
public RankFeatureFieldMapper build(MapperBuilderContext context) { public RankFeatureFieldMapper build(MapperBuilderContext context) {
return new RankFeatureFieldMapper( return new RankFeatureFieldMapper(
name(), leafName(),
new RankFeatureFieldType( new RankFeatureFieldType(
context.buildFullName(name()), context.buildFullName(leafName()),
meta.getValue(), meta.getValue(),
positiveScoreImpact.getValue(), positiveScoreImpact.getValue(),
nullValue.getValue() nullValue.getValue()

View file

@ -64,8 +64,8 @@ public class RankFeaturesFieldMapper extends FieldMapper {
@Override @Override
public RankFeaturesFieldMapper build(MapperBuilderContext context) { public RankFeaturesFieldMapper build(MapperBuilderContext context) {
return new RankFeaturesFieldMapper( return new RankFeaturesFieldMapper(
name(), leafName(),
new RankFeaturesFieldType(context.buildFullName(name()), meta.getValue(), positiveScoreImpact.getValue()), new RankFeaturesFieldType(context.buildFullName(leafName()), meta.getValue(), positiveScoreImpact.getValue()),
multiFieldsBuilder.build(this, context), multiFieldsBuilder.build(this, context),
copyTo, copyTo,
positiveScoreImpact.getValue() positiveScoreImpact.getValue()

View file

@ -187,7 +187,7 @@ public class ScaledFloatFieldMapper extends FieldMapper {
@Override @Override
public ScaledFloatFieldMapper build(MapperBuilderContext context) { public ScaledFloatFieldMapper build(MapperBuilderContext context) {
ScaledFloatFieldType type = new ScaledFloatFieldType( ScaledFloatFieldType type = new ScaledFloatFieldType(
context.buildFullName(name()), context.buildFullName(leafName()),
indexed.getValue(), indexed.getValue(),
stored.getValue(), stored.getValue(),
hasDocValues.getValue(), hasDocValues.getValue(),
@ -198,7 +198,7 @@ public class ScaledFloatFieldMapper extends FieldMapper {
indexMode indexMode
); );
return new ScaledFloatFieldMapper( return new ScaledFloatFieldMapper(
name(), leafName(),
type, type,
multiFieldsBuilder.build(this, context), multiFieldsBuilder.build(this, context),
copyTo, copyTo,

View file

@ -187,7 +187,7 @@ public class SearchAsYouTypeFieldMapper extends FieldMapper {
NamedAnalyzer searchAnalyzer = analyzers.getSearchAnalyzer(); NamedAnalyzer searchAnalyzer = analyzers.getSearchAnalyzer();
SearchAsYouTypeFieldType ft = new SearchAsYouTypeFieldType( SearchAsYouTypeFieldType ft = new SearchAsYouTypeFieldType(
context.buildFullName(name()), context.buildFullName(leafName()),
fieldType, fieldType,
similarity.getValue(), similarity.getValue(),
analyzers.getSearchAnalyzer(), analyzers.getSearchAnalyzer(),
@ -202,7 +202,7 @@ public class SearchAsYouTypeFieldMapper extends FieldMapper {
prefixft.setIndexOptions(fieldType.indexOptions()); prefixft.setIndexOptions(fieldType.indexOptions());
prefixft.setOmitNorms(true); prefixft.setOmitNorms(true);
prefixft.setStored(false); prefixft.setStored(false);
final String fullName = context.buildFullName(name()); final String fullName = context.buildFullName(leafName());
// wrap the root field's index analyzer with shingles and edge ngrams // wrap the root field's index analyzer with shingles and edge ngrams
final Analyzer prefixIndexWrapper = SearchAsYouTypeAnalyzer.withShingleAndPrefix( final Analyzer prefixIndexWrapper = SearchAsYouTypeAnalyzer.withShingleAndPrefix(
indexAnalyzer.analyzer(), indexAnalyzer.analyzer(),
@ -228,7 +228,7 @@ public class SearchAsYouTypeFieldMapper extends FieldMapper {
final int shingleSize = i + 2; final int shingleSize = i + 2;
FieldType shingleft = new FieldType(fieldType); FieldType shingleft = new FieldType(fieldType);
shingleft.setStored(false); shingleft.setStored(false);
String fieldName = getShingleFieldName(context.buildFullName(name()), shingleSize); String fieldName = getShingleFieldName(context.buildFullName(leafName()), shingleSize);
// wrap the root field's index, search, and search quote analyzers with shingles // wrap the root field's index, search, and search quote analyzers with shingles
final SearchAsYouTypeAnalyzer shingleIndexWrapper = SearchAsYouTypeAnalyzer.withShingle( final SearchAsYouTypeAnalyzer shingleIndexWrapper = SearchAsYouTypeAnalyzer.withShingle(
indexAnalyzer.analyzer(), indexAnalyzer.analyzer(),
@ -260,7 +260,7 @@ public class SearchAsYouTypeFieldMapper extends FieldMapper {
ft.setPrefixField(prefixFieldType); ft.setPrefixField(prefixFieldType);
ft.setShingleFields(shingleFieldTypes); ft.setShingleFields(shingleFieldTypes);
return new SearchAsYouTypeFieldMapper( return new SearchAsYouTypeFieldMapper(
name(), leafName(),
ft, ft,
copyTo, copyTo,
indexAnalyzers, indexAnalyzers,

View file

@ -77,17 +77,17 @@ public class TokenCountFieldMapper extends FieldMapper {
@Override @Override
public TokenCountFieldMapper build(MapperBuilderContext context) { public TokenCountFieldMapper build(MapperBuilderContext context) {
if (analyzer.getValue() == null) { if (analyzer.getValue() == null) {
throw new MapperParsingException("Analyzer must be set for field [" + name() + "] but wasn't."); throw new MapperParsingException("Analyzer must be set for field [" + leafName() + "] but wasn't.");
} }
MappedFieldType ft = new TokenCountFieldType( MappedFieldType ft = new TokenCountFieldType(
context.buildFullName(name()), context.buildFullName(leafName()),
index.getValue(), index.getValue(),
store.getValue(), store.getValue(),
hasDocValues.getValue(), hasDocValues.getValue(),
nullValue.getValue(), nullValue.getValue(),
meta.getValue() meta.getValue()
); );
return new TokenCountFieldMapper(name(), ft, multiFieldsBuilder.build(this, context), copyTo, this); return new TokenCountFieldMapper(leafName(), ft, multiFieldsBuilder.build(this, context), copyTo, this);
} }
} }

View file

@ -123,16 +123,16 @@ public final class ParentJoinFieldMapper extends FieldMapper {
"Adding multifields to [" + CONTENT_TYPE + "] mappers has no effect and will be forbidden in future" "Adding multifields to [" + CONTENT_TYPE + "] mappers has no effect and will be forbidden in future"
); );
} }
checkObjectOrNested(context, name()); checkObjectOrNested(context, leafName());
final Map<String, ParentIdFieldMapper> parentIdFields = new HashMap<>(); final Map<String, ParentIdFieldMapper> parentIdFields = new HashMap<>();
relations.get() relations.get()
.stream() .stream()
.map(relation -> new ParentIdFieldMapper(name() + "#" + relation.parent(), eagerGlobalOrdinals.get())) .map(relation -> new ParentIdFieldMapper(leafName() + "#" + relation.parent(), eagerGlobalOrdinals.get()))
.forEach(mapper -> parentIdFields.put(mapper.name(), mapper)); .forEach(mapper -> parentIdFields.put(mapper.name(), mapper));
Joiner joiner = new Joiner(name(), relations.get()); Joiner joiner = new Joiner(leafName(), relations.get());
return new ParentJoinFieldMapper( return new ParentJoinFieldMapper(
name(), leafName(),
new JoinFieldType(context.buildFullName(name()), joiner, meta.get()), new JoinFieldType(context.buildFullName(leafName()), joiner, meta.get()),
Collections.unmodifiableMap(parentIdFields), Collections.unmodifiableMap(parentIdFields),
eagerGlobalOrdinals.get(), eagerGlobalOrdinals.get(),
relations.get() relations.get()

View file

@ -135,10 +135,10 @@ public class PercolatorFieldMapper extends FieldMapper {
@Override @Override
public PercolatorFieldMapper build(MapperBuilderContext context) { public PercolatorFieldMapper build(MapperBuilderContext context) {
PercolatorFieldType fieldType = new PercolatorFieldType(context.buildFullName(name()), meta.getValue()); PercolatorFieldType fieldType = new PercolatorFieldType(context.buildFullName(leafName()), meta.getValue());
// TODO should percolator even allow multifields? // TODO should percolator even allow multifields?
MultiFields multiFields = multiFieldsBuilder.build(this, context); MultiFields multiFields = multiFieldsBuilder.build(this, context);
context = context.createChildContext(name(), null); context = context.createChildContext(leafName(), null);
KeywordFieldMapper extractedTermsField = createExtractQueryFieldBuilder( KeywordFieldMapper extractedTermsField = createExtractQueryFieldBuilder(
EXTRACTED_TERMS_FIELD_NAME, EXTRACTED_TERMS_FIELD_NAME,
context, context,
@ -162,7 +162,7 @@ public class PercolatorFieldMapper extends FieldMapper {
fieldType.mapUnmappedFieldsAsText = mapUnmappedFieldsAsText; fieldType.mapUnmappedFieldsAsText = mapUnmappedFieldsAsText;
return new PercolatorFieldMapper( return new PercolatorFieldMapper(
name(), leafName(),
fieldType, fieldType,
multiFields, multiFields,
copyTo, copyTo,

View file

@ -327,7 +327,7 @@ public class ICUCollationKeywordFieldMapper extends FieldMapper {
final CollatorParams params = collatorParams(); final CollatorParams params = collatorParams();
final Collator collator = params.buildCollator(); final Collator collator = params.buildCollator();
CollationFieldType ft = new CollationFieldType( CollationFieldType ft = new CollationFieldType(
context.buildFullName(name()), context.buildFullName(leafName()),
indexed.getValue(), indexed.getValue(),
stored.getValue(), stored.getValue(),
hasDocValues.getValue(), hasDocValues.getValue(),
@ -337,7 +337,7 @@ public class ICUCollationKeywordFieldMapper extends FieldMapper {
meta.getValue() meta.getValue()
); );
return new ICUCollationKeywordFieldMapper( return new ICUCollationKeywordFieldMapper(
name(), leafName(),
buildFieldType(), buildFieldType(),
ft, ft,
multiFieldsBuilder.build(this, context), multiFieldsBuilder.build(this, context),

View file

@ -139,7 +139,7 @@ public class AnnotatedTextFieldMapper extends FieldMapper {
wrapAnalyzer(analyzers.getSearchQuoteAnalyzer()) wrapAnalyzer(analyzers.getSearchQuoteAnalyzer())
); );
return new AnnotatedTextFieldType( return new AnnotatedTextFieldType(
context.buildFullName(name()), context.buildFullName(leafName()),
store.getValue(), store.getValue(),
tsi, tsi,
context.isSourceSynthetic(), context.isSourceSynthetic(),
@ -158,12 +158,12 @@ public class AnnotatedTextFieldMapper extends FieldMapper {
if (analyzers.positionIncrementGap.isConfigured()) { if (analyzers.positionIncrementGap.isConfigured()) {
if (fieldType.indexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) < 0) { if (fieldType.indexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) < 0) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Cannot set position_increment_gap on field [" + name() + "] without positions enabled" "Cannot set position_increment_gap on field [" + leafName() + "] without positions enabled"
); );
} }
} }
return new AnnotatedTextFieldMapper( return new AnnotatedTextFieldMapper(
name(), leafName(),
fieldType, fieldType,
buildFieldType(fieldType, context, multiFields), buildFieldType(fieldType, context, multiFields),
multiFields, multiFields,

View file

@ -55,8 +55,8 @@ public class Murmur3FieldMapper extends FieldMapper {
@Override @Override
public Murmur3FieldMapper build(MapperBuilderContext context) { public Murmur3FieldMapper build(MapperBuilderContext context) {
return new Murmur3FieldMapper( return new Murmur3FieldMapper(
name(), leafName(),
new Murmur3FieldType(context.buildFullName(name()), stored.getValue(), meta.getValue()), new Murmur3FieldType(context.buildFullName(leafName()), stored.getValue(), meta.getValue()),
multiFieldsBuilder.build(this, context), multiFieldsBuilder.build(this, context),
copyTo copyTo
); );

View file

@ -70,8 +70,8 @@ public class BinaryFieldMapper extends FieldMapper {
@Override @Override
public BinaryFieldMapper build(MapperBuilderContext context) { public BinaryFieldMapper build(MapperBuilderContext context) {
return new BinaryFieldMapper( return new BinaryFieldMapper(
name(), leafName(),
new BinaryFieldType(context.buildFullName(name()), stored.getValue(), hasDocValues.getValue(), meta.getValue()), new BinaryFieldType(context.buildFullName(leafName()), stored.getValue(), hasDocValues.getValue(), meta.getValue()),
multiFieldsBuilder.build(this, context), multiFieldsBuilder.build(this, context),
copyTo, copyTo,
this this

View file

@ -116,7 +116,7 @@ public class BooleanFieldMapper extends FieldMapper {
@Override @Override
public BooleanFieldMapper build(MapperBuilderContext context) { public BooleanFieldMapper build(MapperBuilderContext context) {
MappedFieldType ft = new BooleanFieldType( MappedFieldType ft = new BooleanFieldType(
context.buildFullName(name()), context.buildFullName(leafName()),
indexed.getValue() && indexCreatedVersion.isLegacyIndexVersion() == false, indexed.getValue() && indexCreatedVersion.isLegacyIndexVersion() == false,
stored.getValue(), stored.getValue(),
docValues.getValue(), docValues.getValue(),
@ -124,7 +124,14 @@ public class BooleanFieldMapper extends FieldMapper {
scriptValues(), scriptValues(),
meta.getValue() meta.getValue()
); );
return new BooleanFieldMapper(name(), ft, multiFieldsBuilder.build(this, context), copyTo, context.isSourceSynthetic(), this); return new BooleanFieldMapper(
leafName(),
ft,
multiFieldsBuilder.build(this, context),
copyTo,
context.isSourceSynthetic(),
this
);
} }
private FieldValues<Boolean> scriptValues() { private FieldValues<Boolean> scriptValues() {
@ -134,7 +141,7 @@ public class BooleanFieldMapper extends FieldMapper {
BooleanFieldScript.Factory scriptFactory = scriptCompiler.compile(script.get(), BooleanFieldScript.CONTEXT); BooleanFieldScript.Factory scriptFactory = scriptCompiler.compile(script.get(), BooleanFieldScript.CONTEXT);
return scriptFactory == null return scriptFactory == null
? null ? null
: (lookup, ctx, doc, consumer) -> scriptFactory.newFactory(name(), script.get().getParams(), lookup, OnScriptError.FAIL) : (lookup, ctx, doc, consumer) -> scriptFactory.newFactory(leafName(), script.get().getParams(), lookup, OnScriptError.FAIL)
.newInstance(ctx) .newInstance(ctx)
.runForDoc(doc, consumer); .runForDoc(doc, consumer);
} }

View file

@ -205,9 +205,9 @@ public class CompletionFieldMapper extends FieldMapper {
new CompletionAnalyzer(this.searchAnalyzer.getValue(), preserveSeparators.getValue(), preservePosInc.getValue()) new CompletionAnalyzer(this.searchAnalyzer.getValue(), preserveSeparators.getValue(), preservePosInc.getValue())
); );
CompletionFieldType ft = new CompletionFieldType(context.buildFullName(name()), completionAnalyzer, meta.getValue()); CompletionFieldType ft = new CompletionFieldType(context.buildFullName(leafName()), completionAnalyzer, meta.getValue());
ft.setContextMappings(contexts.getValue()); ft.setContextMappings(contexts.getValue());
return new CompletionFieldMapper(name(), ft, multiFieldsBuilder.build(this, context), copyTo, this); return new CompletionFieldMapper(leafName(), ft, multiFieldsBuilder.build(this, context), copyTo, this);
} }
private void checkCompletionContextsLimit() { private void checkCompletionContextsLimit() {
@ -224,7 +224,7 @@ public class CompletionFieldMapper extends FieldMapper {
+ COMPLETION_CONTEXTS_LIMIT + COMPLETION_CONTEXTS_LIMIT
+ "] completion contexts" + "] completion contexts"
+ " in the mapping for field [" + " in the mapping for field ["
+ name() + leafName()
+ "]. " + "]. "
+ "The maximum allowed number of completion contexts in a mapping will be limited to " + "The maximum allowed number of completion contexts in a mapping will be limited to "
+ "[" + "["

View file

@ -293,7 +293,7 @@ public final class DateFieldMapper extends FieldMapper {
logger.warn(() -> "Error parsing format [" + format.getValue() + "] of legacy index, falling back to default", e); logger.warn(() -> "Error parsing format [" + format.getValue() + "] of legacy index, falling back to default", e);
return DateFormatter.forPattern(format.getDefaultValue()).withLocale(locale.getValue()); return DateFormatter.forPattern(format.getDefaultValue()).withLocale(locale.getValue());
} else { } else {
throw new IllegalArgumentException("Error parsing [format] on field [" + name() + "]: " + e.getMessage(), e); throw new IllegalArgumentException("Error parsing [format] on field [" + leafName() + "]: " + e.getMessage(), e);
} }
} }
} }
@ -306,7 +306,7 @@ public final class DateFieldMapper extends FieldMapper {
return factory == null return factory == null
? null ? null
: (lookup, ctx, doc, consumer) -> factory.newFactory( : (lookup, ctx, doc, consumer) -> factory.newFactory(
name(), leafName(),
script.get().getParams(), script.get().getParams(),
lookup, lookup,
buildFormatter(), buildFormatter(),
@ -327,7 +327,7 @@ public final class DateFieldMapper extends FieldMapper {
return fieldType.parse(nullValue.getValue()); return fieldType.parse(nullValue.getValue());
} catch (Exception e) { } catch (Exception e) {
if (indexCreatedVersion.onOrAfter(IndexVersions.V_8_0_0)) { if (indexCreatedVersion.onOrAfter(IndexVersions.V_8_0_0)) {
throw new MapperParsingException("Error parsing [null_value] on field [" + name() + "]: " + e.getMessage(), e); throw new MapperParsingException("Error parsing [null_value] on field [" + leafName() + "]: " + e.getMessage(), e);
} else { } else {
DEPRECATION_LOGGER.warn( DEPRECATION_LOGGER.warn(
DeprecationCategory.MAPPINGS, DeprecationCategory.MAPPINGS,
@ -335,7 +335,7 @@ public final class DateFieldMapper extends FieldMapper {
"Error parsing [" "Error parsing ["
+ nullValue.getValue() + nullValue.getValue()
+ "] as date in [null_value] on field [" + "] as date in [null_value] on field ["
+ name() + leafName()
+ "]); [null_value] will be ignored" + "]); [null_value] will be ignored"
); );
return null; return null;
@ -346,7 +346,7 @@ public final class DateFieldMapper extends FieldMapper {
@Override @Override
public DateFieldMapper build(MapperBuilderContext context) { public DateFieldMapper build(MapperBuilderContext context) {
DateFieldType ft = new DateFieldType( DateFieldType ft = new DateFieldType(
context.buildFullName(name()), context.buildFullName(leafName()),
index.getValue() && indexCreatedVersion.isLegacyIndexVersion() == false, index.getValue() && indexCreatedVersion.isLegacyIndexVersion() == false,
index.getValue(), index.getValue(),
store.getValue(), store.getValue(),
@ -359,13 +359,13 @@ public final class DateFieldMapper extends FieldMapper {
); );
Long nullTimestamp = parseNullValue(ft); Long nullTimestamp = parseNullValue(ft);
if (name().equals(DataStreamTimestampFieldMapper.DEFAULT_PATH) if (leafName().equals(DataStreamTimestampFieldMapper.DEFAULT_PATH)
&& context.isDataStream() && context.isDataStream()
&& ignoreMalformed.isConfigured() == false) { && ignoreMalformed.isConfigured() == false) {
ignoreMalformed.setValue(false); ignoreMalformed.setValue(false);
} }
return new DateFieldMapper( return new DateFieldMapper(
name(), leafName(),
ft, ft,
multiFieldsBuilder.build(this, context), multiFieldsBuilder.build(this, context),
copyTo, copyTo,

View file

@ -151,8 +151,8 @@ public final class FieldAliasMapper extends Mapper {
@Override @Override
public FieldAliasMapper build(MapperBuilderContext context) { public FieldAliasMapper build(MapperBuilderContext context) {
String fullName = context.buildFullName(name()); String fullName = context.buildFullName(leafName());
return new FieldAliasMapper(name(), fullName, path); return new FieldAliasMapper(leafName(), fullName, path);
} }
} }

View file

@ -514,7 +514,7 @@ public abstract class FieldMapper extends Mapper {
private boolean hasSyntheticSourceCompatibleKeywordField; private boolean hasSyntheticSourceCompatibleKeywordField;
public Builder add(FieldMapper.Builder builder) { public Builder add(FieldMapper.Builder builder) {
mapperBuilders.put(builder.name(), builder::build); mapperBuilders.put(builder.leafName(), builder::build);
if (builder instanceof KeywordFieldMapper.Builder kwd) { if (builder instanceof KeywordFieldMapper.Builder kwd) {
if (kwd.hasNormalizer() == false && (kwd.hasDocValues() || kwd.isStored())) { if (kwd.hasNormalizer() == false && (kwd.hasDocValues() || kwd.isStored())) {
@ -559,7 +559,7 @@ public abstract class FieldMapper extends Mapper {
return empty(); return empty();
} else { } else {
FieldMapper[] mappers = new FieldMapper[mapperBuilders.size()]; FieldMapper[] mappers = new FieldMapper[mapperBuilders.size()];
context = context.createChildContext(mainFieldBuilder.name(), null); context = context.createChildContext(mainFieldBuilder.leafName(), null);
int i = 0; int i = 0;
for (Map.Entry<String, Function<MapperBuilderContext, FieldMapper>> entry : this.mapperBuilders.entrySet()) { for (Map.Entry<String, Function<MapperBuilderContext, FieldMapper>> entry : this.mapperBuilders.entrySet()) {
mappers[i++] = entry.getValue().apply(context); mappers[i++] = entry.getValue().apply(context);

View file

@ -188,7 +188,7 @@ public class GeoPointFieldMapper extends AbstractPointGeometryFieldMapper<GeoPoi
GeoPointFieldScript.Factory factory = scriptCompiler.compile(this.script.get(), GeoPointFieldScript.CONTEXT); GeoPointFieldScript.Factory factory = scriptCompiler.compile(this.script.get(), GeoPointFieldScript.CONTEXT);
return factory == null return factory == null
? null ? null
: (lookup, ctx, doc, consumer) -> factory.newFactory(name(), script.get().getParams(), lookup, OnScriptError.FAIL) : (lookup, ctx, doc, consumer) -> factory.newFactory(leafName(), script.get().getParams(), lookup, OnScriptError.FAIL)
.newInstance(ctx) .newInstance(ctx)
.runForDoc(doc, consumer); .runForDoc(doc, consumer);
} }
@ -197,7 +197,7 @@ public class GeoPointFieldMapper extends AbstractPointGeometryFieldMapper<GeoPoi
public FieldMapper build(MapperBuilderContext context) { public FieldMapper build(MapperBuilderContext context) {
boolean ignoreMalformedEnabled = ignoreMalformed.get().value(); boolean ignoreMalformedEnabled = ignoreMalformed.get().value();
Parser<GeoPoint> geoParser = new GeoPointParser( Parser<GeoPoint> geoParser = new GeoPointParser(
name(), leafName(),
(parser) -> GeoUtils.parseGeoPoint(parser, ignoreZValue.get().value()), (parser) -> GeoUtils.parseGeoPoint(parser, ignoreZValue.get().value()),
nullValue.get(), nullValue.get(),
ignoreZValue.get().value(), ignoreZValue.get().value(),
@ -206,7 +206,7 @@ public class GeoPointFieldMapper extends AbstractPointGeometryFieldMapper<GeoPoi
context.isSourceSynthetic() && ignoreMalformedEnabled context.isSourceSynthetic() && ignoreMalformedEnabled
); );
GeoPointFieldType ft = new GeoPointFieldType( GeoPointFieldType ft = new GeoPointFieldType(
context.buildFullName(name()), context.buildFullName(leafName()),
indexed.get() && indexCreatedVersion.isLegacyIndexVersion() == false, indexed.get() && indexCreatedVersion.isLegacyIndexVersion() == false,
stored.get(), stored.get(),
hasDocValues.get(), hasDocValues.get(),
@ -218,9 +218,9 @@ public class GeoPointFieldMapper extends AbstractPointGeometryFieldMapper<GeoPoi
indexMode indexMode
); );
if (this.script.get() == null) { if (this.script.get() == null) {
return new GeoPointFieldMapper(name(), ft, multiFieldsBuilder.build(this, context), copyTo, geoParser, this); return new GeoPointFieldMapper(leafName(), ft, multiFieldsBuilder.build(this, context), copyTo, geoParser, this);
} }
return new GeoPointFieldMapper(name(), ft, geoParser, this); return new GeoPointFieldMapper(leafName(), ft, geoParser, this);
} }
} }

View file

@ -99,18 +99,18 @@ public class GeoShapeFieldMapper extends AbstractShapeGeometryFieldMapper<Geomet
); );
GeoShapeParser geoShapeParser = new GeoShapeParser(geometryParser, orientation.get().value()); GeoShapeParser geoShapeParser = new GeoShapeParser(geometryParser, orientation.get().value());
GeoShapeFieldType ft = new GeoShapeFieldType( GeoShapeFieldType ft = new GeoShapeFieldType(
context.buildFullName(name()), context.buildFullName(leafName()),
indexed.get(), indexed.get(),
orientation.get().value(), orientation.get().value(),
geoShapeParser, geoShapeParser,
meta.get() meta.get()
); );
return new GeoShapeFieldMapper( return new GeoShapeFieldMapper(
name(), leafName(),
ft, ft,
multiFieldsBuilder.build(this, context), multiFieldsBuilder.build(this, context),
copyTo, copyTo,
new GeoShapeIndexer(orientation.get().value(), context.buildFullName(name())), new GeoShapeIndexer(orientation.get().value(), context.buildFullName(leafName())),
geoShapeParser, geoShapeParser,
this this
); );

View file

@ -131,7 +131,7 @@ public class IpFieldMapper extends FieldMapper {
return InetAddresses.forString(nullValueAsString); return InetAddresses.forString(nullValueAsString);
} catch (Exception e) { } catch (Exception e) {
if (indexCreatedVersion.onOrAfter(IndexVersions.V_8_0_0)) { if (indexCreatedVersion.onOrAfter(IndexVersions.V_8_0_0)) {
throw new MapperParsingException("Error parsing [null_value] on field [" + name() + "]: " + e.getMessage(), e); throw new MapperParsingException("Error parsing [null_value] on field [" + leafName() + "]: " + e.getMessage(), e);
} else { } else {
DEPRECATION_LOGGER.warn( DEPRECATION_LOGGER.warn(
DeprecationCategory.MAPPINGS, DeprecationCategory.MAPPINGS,
@ -139,7 +139,7 @@ public class IpFieldMapper extends FieldMapper {
"Error parsing [" "Error parsing ["
+ nullValue.getValue() + nullValue.getValue()
+ "] as IP in [null_value] on field [" + "] as IP in [null_value] on field ["
+ name() + leafName()
+ "]); [null_value] will be ignored" + "]); [null_value] will be ignored"
); );
return null; return null;
@ -154,7 +154,7 @@ public class IpFieldMapper extends FieldMapper {
IpFieldScript.Factory factory = scriptCompiler.compile(this.script.get(), IpFieldScript.CONTEXT); IpFieldScript.Factory factory = scriptCompiler.compile(this.script.get(), IpFieldScript.CONTEXT);
return factory == null return factory == null
? null ? null
: (lookup, ctx, doc, consumer) -> factory.newFactory(name(), script.get().getParams(), lookup, OnScriptError.FAIL) : (lookup, ctx, doc, consumer) -> factory.newFactory(leafName(), script.get().getParams(), lookup, OnScriptError.FAIL)
.newInstance(ctx) .newInstance(ctx)
.runForDoc(doc, consumer); .runForDoc(doc, consumer);
} }
@ -170,9 +170,9 @@ public class IpFieldMapper extends FieldMapper {
dimension.setValue(true); dimension.setValue(true);
} }
return new IpFieldMapper( return new IpFieldMapper(
name(), leafName(),
new IpFieldType( new IpFieldType(
context.buildFullName(name()), context.buildFullName(leafName()),
indexed.getValue() && indexCreatedVersion.isLegacyIndexVersion() == false, indexed.getValue() && indexCreatedVersion.isLegacyIndexVersion() == false,
stored.getValue(), stored.getValue(),
hasDocValues.getValue(), hasDocValues.getValue(),

View file

@ -271,7 +271,7 @@ public final class KeywordFieldMapper extends FieldMapper {
StringFieldScript.Factory scriptFactory = scriptCompiler.compile(script.get(), StringFieldScript.CONTEXT); StringFieldScript.Factory scriptFactory = scriptCompiler.compile(script.get(), StringFieldScript.CONTEXT);
return scriptFactory == null return scriptFactory == null
? null ? null
: (lookup, ctx, doc, consumer) -> scriptFactory.newFactory(name(), script.get().getParams(), lookup, OnScriptError.FAIL) : (lookup, ctx, doc, consumer) -> scriptFactory.newFactory(leafName(), script.get().getParams(), lookup, OnScriptError.FAIL)
.newInstance(ctx) .newInstance(ctx)
.runForDoc(doc, consumer); .runForDoc(doc, consumer);
} }
@ -311,7 +311,7 @@ public final class KeywordFieldMapper extends FieldMapper {
); );
normalizer = Lucene.KEYWORD_ANALYZER; normalizer = Lucene.KEYWORD_ANALYZER;
} else { } else {
throw new MapperParsingException("normalizer [" + normalizerName + "] not found for field [" + name() + "]"); throw new MapperParsingException("normalizer [" + normalizerName + "] not found for field [" + leafName() + "]");
} }
} }
searchAnalyzer = quoteAnalyzer = normalizer; searchAnalyzer = quoteAnalyzer = normalizer;
@ -325,7 +325,7 @@ public final class KeywordFieldMapper extends FieldMapper {
dimension(true); dimension(true);
} }
return new KeywordFieldType( return new KeywordFieldType(
context.buildFullName(name()), context.buildFullName(leafName()),
fieldType, fieldType,
normalizer, normalizer,
searchAnalyzer, searchAnalyzer,
@ -347,7 +347,7 @@ public final class KeywordFieldMapper extends FieldMapper {
fieldtype = Defaults.FIELD_TYPE; fieldtype = Defaults.FIELD_TYPE;
} }
return new KeywordFieldMapper( return new KeywordFieldMapper(
name(), leafName(),
fieldtype, fieldtype,
buildFieldType(context, fieldtype), buildFieldType(context, fieldtype),
multiFieldsBuilder.build(this, context), multiFieldsBuilder.build(this, context),

View file

@ -24,22 +24,21 @@ public abstract class Mapper implements ToXContentFragment, Iterable<Mapper> {
public abstract static class Builder { public abstract static class Builder {
private String name; private String leafName;
protected Builder(String name) { protected Builder(String leafName) {
setName(name); setLeafName(leafName);
} }
// TODO rename this to leafName? public final String leafName() {
public final String name() { return this.leafName;
return this.name;
} }
/** Returns a newly built mapper. */ /** Returns a newly built mapper. */
public abstract Mapper build(MapperBuilderContext context); public abstract Mapper build(MapperBuilderContext context);
void setName(String name) { void setLeafName(String leafName) {
this.name = internFieldName(name); this.leafName = internFieldName(leafName);
} }
} }

View file

@ -82,7 +82,7 @@ public class NestedObjectMapper extends ObjectMapper {
} }
parentTypeFilter = Queries.newNonNestedFilter(indexCreatedVersion); parentTypeFilter = Queries.newNonNestedFilter(indexCreatedVersion);
} }
final String fullPath = context.buildFullName(name()); final String fullPath = context.buildFullName(leafName());
final String nestedTypePath; final String nestedTypePath;
if (indexCreatedVersion.before(IndexVersions.V_8_0_0)) { if (indexCreatedVersion.before(IndexVersions.V_8_0_0)) {
nestedTypePath = "__" + fullPath; nestedTypePath = "__" + fullPath;
@ -91,14 +91,14 @@ public class NestedObjectMapper extends ObjectMapper {
} }
final Query nestedTypeFilter = NestedPathFieldMapper.filter(indexCreatedVersion, nestedTypePath); final Query nestedTypeFilter = NestedPathFieldMapper.filter(indexCreatedVersion, nestedTypePath);
NestedMapperBuilderContext nestedContext = new NestedMapperBuilderContext( NestedMapperBuilderContext nestedContext = new NestedMapperBuilderContext(
context.buildFullName(name()), context.buildFullName(leafName()),
nestedTypeFilter, nestedTypeFilter,
parentIncludedInRoot, parentIncludedInRoot,
context.getDynamic(dynamic), context.getDynamic(dynamic),
context.getMergeReason() context.getMergeReason()
); );
return new NestedObjectMapper( return new NestedObjectMapper(
name(), leafName(),
fullPath, fullPath,
buildMappers(nestedContext), buildMappers(nestedContext),
enabled, enabled,

View file

@ -221,7 +221,7 @@ public class NumberFieldMapper extends FieldMapper {
if (this.script.get() == null) { if (this.script.get() == null) {
return null; return null;
} }
return type.compile(name(), script.get(), scriptCompiler); return type.compile(leafName(), script.get(), scriptCompiler);
} }
public Builder dimension(boolean dimension) { public Builder dimension(boolean dimension) {
@ -265,8 +265,15 @@ public class NumberFieldMapper extends FieldMapper {
dimension.setValue(true); dimension.setValue(true);
} }
MappedFieldType ft = new NumberFieldType(context.buildFullName(name()), this); MappedFieldType ft = new NumberFieldType(context.buildFullName(leafName()), this);
return new NumberFieldMapper(name(), ft, multiFieldsBuilder.build(this, context), copyTo, context.isSourceSynthetic(), this); return new NumberFieldMapper(
leafName(),
ft,
multiFieldsBuilder.build(this, context),
copyTo,
context.isSourceSynthetic(),
this
);
} }
} }

View file

@ -188,13 +188,13 @@ public class ObjectMapper extends Mapper {
@Override @Override
public ObjectMapper build(MapperBuilderContext context) { public ObjectMapper build(MapperBuilderContext context) {
return new ObjectMapper( return new ObjectMapper(
name(), leafName(),
context.buildFullName(name()), context.buildFullName(leafName()),
enabled, enabled,
subobjects, subobjects,
storeArraySource, storeArraySource,
dynamic, dynamic,
buildMappers(context.createChildContext(name(), dynamic)) buildMappers(context.createChildContext(leafName(), dynamic))
); );
} }
} }
@ -325,7 +325,7 @@ public class ObjectMapper extends Mapper {
"Tried to add nested object [" "Tried to add nested object ["
+ fieldName + fieldName
+ "] to object [" + "] to object ["
+ objBuilder.name() + objBuilder.leafName()
+ "] which does not support subobjects" + "] which does not support subobjects"
); );
} }
@ -660,7 +660,7 @@ public class ObjectMapper extends Mapper {
for (Mapper mapper : mappers.values()) { for (Mapper mapper : mappers.values()) {
if (mapper instanceof FieldMapper fieldMapper) { if (mapper instanceof FieldMapper fieldMapper) {
FieldMapper.Builder fieldBuilder = fieldMapper.getMergeBuilder(); FieldMapper.Builder fieldBuilder = fieldMapper.getMergeBuilder();
fieldBuilder.setName(path.pathAsText(mapper.simpleName())); fieldBuilder.setLeafName(path.pathAsText(mapper.simpleName()));
flattenedMappers.add(fieldBuilder.build(context)); flattenedMappers.add(fieldBuilder.build(context));
} else if (mapper instanceof ObjectMapper objectMapper) { } else if (mapper instanceof ObjectMapper objectMapper) {
objectMapper.asFlattenedFieldMappers(context, flattenedMappers, path); objectMapper.asFlattenedFieldMappers(context, flattenedMappers, path);

View file

@ -77,11 +77,11 @@ public class PassThroughObjectMapper extends ObjectMapper {
@Override @Override
public PassThroughObjectMapper build(MapperBuilderContext context) { public PassThroughObjectMapper build(MapperBuilderContext context) {
return new PassThroughObjectMapper( return new PassThroughObjectMapper(
name(), leafName(),
context.buildFullName(name()), context.buildFullName(leafName()),
enabled, enabled,
dynamic, dynamic,
buildMappers(context.createChildContext(name(), timeSeriesDimensionSubFields.value(), dynamic)), buildMappers(context.createChildContext(leafName(), timeSeriesDimensionSubFields.value(), dynamic)),
timeSeriesDimensionSubFields, timeSeriesDimensionSubFields,
priority priority
); );

View file

@ -90,8 +90,8 @@ public class PlaceHolderFieldMapper extends FieldMapper {
@Override @Override
public PlaceHolderFieldMapper build(MapperBuilderContext context) { public PlaceHolderFieldMapper build(MapperBuilderContext context) {
PlaceHolderFieldType mappedFieldType = new PlaceHolderFieldType(context.buildFullName(name()), type, Map.of()); PlaceHolderFieldType mappedFieldType = new PlaceHolderFieldType(context.buildFullName(leafName()), type, Map.of());
return new PlaceHolderFieldMapper(name(), mappedFieldType, multiFieldsBuilder.build(this, context), copyTo, unknownParams); return new PlaceHolderFieldMapper(leafName(), mappedFieldType, multiFieldsBuilder.build(this, context), copyTo, unknownParams);
} }
} }

View file

@ -120,12 +120,12 @@ public class RangeFieldMapper extends FieldMapper {
} }
protected RangeFieldType setupFieldType(MapperBuilderContext context) { protected RangeFieldType setupFieldType(MapperBuilderContext context) {
String fullName = context.buildFullName(name()); String fullName = context.buildFullName(leafName());
if (format.isConfigured()) { if (format.isConfigured()) {
if (type != RangeType.DATE) { if (type != RangeType.DATE) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"field [" "field ["
+ name() + leafName()
+ "] of type [range]" + "] of type [range]"
+ " should not define a dateTimeFormatter unless it is a " + " should not define a dateTimeFormatter unless it is a "
+ RangeType.DATE + RangeType.DATE
@ -167,7 +167,7 @@ public class RangeFieldMapper extends FieldMapper {
@Override @Override
public RangeFieldMapper build(MapperBuilderContext context) { public RangeFieldMapper build(MapperBuilderContext context) {
RangeFieldType ft = setupFieldType(context); RangeFieldType ft = setupFieldType(context);
return new RangeFieldMapper(name(), ft, multiFieldsBuilder.build(this, context), copyTo, type, this); return new RangeFieldMapper(leafName(), ft, multiFieldsBuilder.build(this, context), copyTo, type, this);
} }
} }

View file

@ -108,7 +108,7 @@ public class RootObjectMapper extends ObjectMapper {
@Override @Override
public RootObjectMapper build(MapperBuilderContext context) { public RootObjectMapper build(MapperBuilderContext context) {
return new RootObjectMapper( return new RootObjectMapper(
name(), leafName(),
enabled, enabled,
subobjects, subobjects,
storeArraySource, storeArraySource,

View file

@ -374,18 +374,18 @@ public final class TextFieldMapper extends FieldMapper {
if (analyzers.positionIncrementGap.isConfigured()) { if (analyzers.positionIncrementGap.isConfigured()) {
if (fieldType.indexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) < 0) { if (fieldType.indexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) < 0) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Cannot set position_increment_gap on field [" + name() + "] without positions enabled" "Cannot set position_increment_gap on field [" + leafName() + "] without positions enabled"
); );
} }
} }
TextSearchInfo tsi = new TextSearchInfo(fieldType, similarity.getValue(), searchAnalyzer, searchQuoteAnalyzer); TextSearchInfo tsi = new TextSearchInfo(fieldType, similarity.getValue(), searchAnalyzer, searchQuoteAnalyzer);
TextFieldType ft; TextFieldType ft;
if (indexCreatedVersion.isLegacyIndexVersion()) { if (indexCreatedVersion.isLegacyIndexVersion()) {
ft = new LegacyTextFieldType(context.buildFullName(name()), index.getValue(), store.getValue(), tsi, meta.getValue()); ft = new LegacyTextFieldType(context.buildFullName(leafName()), index.getValue(), store.getValue(), tsi, meta.getValue());
// ignore fieldData and eagerGlobalOrdinals // ignore fieldData and eagerGlobalOrdinals
} else { } else {
ft = new TextFieldType( ft = new TextFieldType(
context.buildFullName(name()), context.buildFullName(leafName()),
index.getValue(), index.getValue(),
store.getValue(), store.getValue(),
tsi, tsi,
@ -407,7 +407,7 @@ public final class TextFieldMapper extends FieldMapper {
return null; return null;
} }
if (index.getValue() == false) { if (index.getValue() == false) {
throw new IllegalArgumentException("Cannot set index_prefixes on unindexed field [" + name() + "]"); throw new IllegalArgumentException("Cannot set index_prefixes on unindexed field [" + leafName() + "]");
} }
/* /*
* Mappings before v7.2.1 use {@link Builder#name} instead of {@link Builder#fullName} * Mappings before v7.2.1 use {@link Builder#name} instead of {@link Builder#fullName}
@ -416,7 +416,7 @@ public final class TextFieldMapper extends FieldMapper {
* or a multi-field). This way search will continue to work on old indices and new indices * or a multi-field). This way search will continue to work on old indices and new indices
* will use the expected full name. * will use the expected full name.
*/ */
String fullName = indexCreatedVersion.before(IndexVersions.V_7_2_1) ? name() : context.buildFullName(name()); String fullName = indexCreatedVersion.before(IndexVersions.V_7_2_1) ? leafName() : context.buildFullName(leafName());
// Copy the index options of the main field to allow phrase queries on // Copy the index options of the main field to allow phrase queries on
// the prefix field. // the prefix field.
FieldType pft = new FieldType(fieldType); FieldType pft = new FieldType(fieldType);
@ -448,10 +448,10 @@ public final class TextFieldMapper extends FieldMapper {
return null; return null;
} }
if (index.get() == false) { if (index.get() == false) {
throw new IllegalArgumentException("Cannot set index_phrases on unindexed field [" + name() + "]"); throw new IllegalArgumentException("Cannot set index_phrases on unindexed field [" + leafName() + "]");
} }
if (fieldType.indexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) < 0) { if (fieldType.indexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) < 0) {
throw new IllegalArgumentException("Cannot set index_phrases on field [" + name() + "] if positions are not enabled"); throw new IllegalArgumentException("Cannot set index_phrases on field [" + leafName() + "] if positions are not enabled");
} }
FieldType phraseFieldType = new FieldType(fieldType); FieldType phraseFieldType = new FieldType(fieldType);
PhraseWrappedAnalyzer a = new PhraseWrappedAnalyzer( PhraseWrappedAnalyzer a = new PhraseWrappedAnalyzer(
@ -480,7 +480,7 @@ public final class TextFieldMapper extends FieldMapper {
throw new MapperParsingException("Cannot use reserved field name [" + mapper.name() + "]"); throw new MapperParsingException("Cannot use reserved field name [" + mapper.name() + "]");
} }
} }
return new TextFieldMapper(name(), fieldType, tft, prefixFieldInfo, phraseFieldInfo, multiFields, copyTo, this); return new TextFieldMapper(leafName(), fieldType, tft, prefixFieldInfo, phraseFieldInfo, multiFields, copyTo, this);
} }
} }

View file

@ -202,13 +202,13 @@ public final class FlattenedFieldMapper extends FieldMapper {
public FlattenedFieldMapper build(MapperBuilderContext context) { public FlattenedFieldMapper build(MapperBuilderContext context) {
MultiFields multiFields = multiFieldsBuilder.build(this, context); MultiFields multiFields = multiFieldsBuilder.build(this, context);
if (multiFields.iterator().hasNext()) { if (multiFields.iterator().hasNext()) {
throw new IllegalArgumentException(CONTENT_TYPE + " field [" + name() + "] does not support [fields]"); throw new IllegalArgumentException(CONTENT_TYPE + " field [" + leafName() + "] does not support [fields]");
} }
if (copyTo.copyToFields().isEmpty() == false) { if (copyTo.copyToFields().isEmpty() == false) {
throw new IllegalArgumentException(CONTENT_TYPE + " field [" + name() + "] does not support [copy_to]"); throw new IllegalArgumentException(CONTENT_TYPE + " field [" + leafName() + "] does not support [copy_to]");
} }
MappedFieldType ft = new RootFlattenedFieldType( MappedFieldType ft = new RootFlattenedFieldType(
context.buildFullName(name()), context.buildFullName(leafName()),
indexed.get(), indexed.get(),
hasDocValues.get(), hasDocValues.get(),
meta.get(), meta.get(),
@ -216,7 +216,7 @@ public final class FlattenedFieldMapper extends FieldMapper {
eagerGlobalOrdinals.get(), eagerGlobalOrdinals.get(),
dimensions.get() dimensions.get()
); );
return new FlattenedFieldMapper(name(), ft, this); return new FlattenedFieldMapper(leafName(), ft, this);
} }
} }

View file

@ -245,9 +245,9 @@ public class DenseVectorFieldMapper extends FieldMapper {
@Override @Override
public DenseVectorFieldMapper build(MapperBuilderContext context) { public DenseVectorFieldMapper build(MapperBuilderContext context) {
return new DenseVectorFieldMapper( return new DenseVectorFieldMapper(
name(), leafName(),
new DenseVectorFieldType( new DenseVectorFieldType(
context.buildFullName(name()), context.buildFullName(leafName()),
indexVersionCreated, indexVersionCreated,
elementType.getValue(), elementType.getValue(),
dims.getValue(), dims.getValue(),

View file

@ -67,8 +67,8 @@ public class SparseVectorFieldMapper extends FieldMapper {
@Override @Override
public SparseVectorFieldMapper build(MapperBuilderContext context) { public SparseVectorFieldMapper build(MapperBuilderContext context) {
return new SparseVectorFieldMapper( return new SparseVectorFieldMapper(
name(), leafName(),
new SparseVectorFieldType(context.buildFullName(name()), meta.getValue()), new SparseVectorFieldType(context.buildFullName(leafName()), meta.getValue()),
multiFieldsBuilder.build(this, context), multiFieldsBuilder.build(this, context),
copyTo copyTo
); );

View file

@ -135,7 +135,7 @@ public class MappingLookupInferenceFieldMapperTests extends MapperServiceTestCas
@Override @Override
public FieldMapper build(MapperBuilderContext context) { public FieldMapper build(MapperBuilderContext context) {
return new TestInferenceFieldMapper(name()); return new TestInferenceFieldMapper(leafName());
} }
} }

View file

@ -64,7 +64,7 @@ public class NonDynamicFieldMapperTests extends NonDynamicFieldMapperTestCase {
@Override @Override
public NonDynamicFieldMapper build(MapperBuilderContext context) { public NonDynamicFieldMapper build(MapperBuilderContext context) {
return new NonDynamicFieldMapper(name(), new TextFieldMapper.TextFieldType(name(), false, true, meta.getValue())); return new NonDynamicFieldMapper(leafName(), new TextFieldMapper.TextFieldType(leafName(), false, true, meta.getValue()));
} }
} }

View file

@ -176,7 +176,7 @@ public class ParametrizedMapperTests extends MapperServiceTestCase {
@Override @Override
public FieldMapper build(MapperBuilderContext context) { public FieldMapper build(MapperBuilderContext context) {
return new TestMapper(name(), context.buildFullName(name()), multiFieldsBuilder.build(this, context), copyTo, this); return new TestMapper(leafName(), context.buildFullName(leafName()), multiFieldsBuilder.build(this, context), copyTo, this);
} }
} }

View file

@ -92,7 +92,7 @@ public class MockFieldMapper extends FieldMapper {
@Override @Override
public MockFieldMapper build(MapperBuilderContext context) { public MockFieldMapper build(MapperBuilderContext context) {
MultiFields multiFields = multiFieldsBuilder.build(this, context); MultiFields multiFields = multiFieldsBuilder.build(this, context);
return new MockFieldMapper(name(), fieldType, multiFields, copyTo); return new MockFieldMapper(leafName(), fieldType, multiFields, copyTo);
} }
} }
} }

View file

@ -97,8 +97,8 @@ public class HistogramFieldMapper extends FieldMapper {
@Override @Override
public HistogramFieldMapper build(MapperBuilderContext context) { public HistogramFieldMapper build(MapperBuilderContext context) {
return new HistogramFieldMapper( return new HistogramFieldMapper(
name(), leafName(),
new HistogramFieldType(context.buildFullName(name()), meta.getValue()), new HistogramFieldType(context.buildFullName(leafName()), meta.getValue()),
multiFieldsBuilder.build(this, context), multiFieldsBuilder.build(this, context),
copyTo, copyTo,
this this

View file

@ -146,16 +146,16 @@ public class SemanticTextFieldMapper extends FieldMapper implements InferenceFie
@Override @Override
public SemanticTextFieldMapper build(MapperBuilderContext context) { public SemanticTextFieldMapper build(MapperBuilderContext context) {
if (copyTo.copyToFields().isEmpty() == false) { if (copyTo.copyToFields().isEmpty() == false) {
throw new IllegalArgumentException(CONTENT_TYPE + " field [" + name() + "] does not support [copy_to]"); throw new IllegalArgumentException(CONTENT_TYPE + " field [" + leafName() + "] does not support [copy_to]");
} }
if (multiFieldsBuilder.hasMultiFields()) { if (multiFieldsBuilder.hasMultiFields()) {
throw new IllegalArgumentException(CONTENT_TYPE + " field [" + name() + "] does not support multi-fields"); throw new IllegalArgumentException(CONTENT_TYPE + " field [" + leafName() + "] does not support multi-fields");
} }
final String fullName = context.buildFullName(name()); final String fullName = context.buildFullName(leafName());
var childContext = context.createChildContext(name(), ObjectMapper.Dynamic.FALSE); var childContext = context.createChildContext(leafName(), ObjectMapper.Dynamic.FALSE);
final ObjectMapper inferenceField = inferenceFieldBuilder.apply(childContext); final ObjectMapper inferenceField = inferenceFieldBuilder.apply(childContext);
return new SemanticTextFieldMapper( return new SemanticTextFieldMapper(
name(), leafName(),
new SemanticTextFieldType( new SemanticTextFieldType(
fullName, fullName,
inferenceId.getValue(), inferenceId.getValue(),

View file

@ -143,7 +143,7 @@ public class AggregateDoubleMetricFieldMapper extends FieldMapper {
return parsedMetrics; return parsedMetrics;
}, m -> toType(m).metrics, XContentBuilder::enumSet, Objects::toString).addValidator(v -> { }, m -> toType(m).metrics, XContentBuilder::enumSet, Objects::toString).addValidator(v -> {
if (v == null || v.isEmpty()) { if (v == null || v.isEmpty()) {
throw new IllegalArgumentException("Property [" + Names.METRICS + "] is required for field [" + name() + "]."); throw new IllegalArgumentException("Property [" + Names.METRICS + "] is required for field [" + leafName() + "].");
} }
}); });
@ -209,21 +209,23 @@ public class AggregateDoubleMetricFieldMapper extends FieldMapper {
} }
if (metrics.getValue().contains(defaultMetric.getValue()) == false) { if (metrics.getValue().contains(defaultMetric.getValue()) == false) {
throw new IllegalArgumentException("Property [" + Names.DEFAULT_METRIC + "] is required for field [" + name() + "]."); throw new IllegalArgumentException(
"Property [" + Names.DEFAULT_METRIC + "] is required for field [" + leafName() + "]."
);
} }
} }
if (metrics.getValue().contains(defaultMetric.getValue()) == false) { if (metrics.getValue().contains(defaultMetric.getValue()) == false) {
// The default_metric is not defined in the "metrics" field // The default_metric is not defined in the "metrics" field
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Default metric [" + defaultMetric.getValue() + "] is not defined in the metrics of field [" + name() + "]." "Default metric [" + defaultMetric.getValue() + "] is not defined in the metrics of field [" + leafName() + "]."
); );
} }
EnumMap<Metric, NumberFieldMapper> metricMappers = new EnumMap<>(Metric.class); EnumMap<Metric, NumberFieldMapper> metricMappers = new EnumMap<>(Metric.class);
// Instantiate one NumberFieldMapper instance for each metric // Instantiate one NumberFieldMapper instance for each metric
for (Metric m : this.metrics.getValue()) { for (Metric m : this.metrics.getValue()) {
String fieldName = subfieldName(name(), m); String fieldName = subfieldName(leafName(), m);
NumberFieldMapper.Builder builder; NumberFieldMapper.Builder builder;
if (m == Metric.value_count) { if (m == Metric.value_count) {
@ -259,14 +261,14 @@ public class AggregateDoubleMetricFieldMapper extends FieldMapper {
}, () -> new EnumMap<>(Metric.class))); }, () -> new EnumMap<>(Metric.class)));
AggregateDoubleMetricFieldType metricFieldType = new AggregateDoubleMetricFieldType( AggregateDoubleMetricFieldType metricFieldType = new AggregateDoubleMetricFieldType(
context.buildFullName(name()), context.buildFullName(leafName()),
meta.getValue(), meta.getValue(),
timeSeriesMetric.getValue() timeSeriesMetric.getValue()
); );
metricFieldType.setMetricFields(metricFields); metricFieldType.setMetricFields(metricFields);
metricFieldType.setDefaultMetric(defaultMetric.getValue()); metricFieldType.setDefaultMetric(defaultMetric.getValue());
return new AggregateDoubleMetricFieldMapper(name(), metricFieldType, metricMappers, this); return new AggregateDoubleMetricFieldMapper(leafName(), metricFieldType, metricMappers, this);
} }
} }

View file

@ -110,8 +110,8 @@ public class ConstantKeywordFieldMapper extends FieldMapper {
); );
} }
return new ConstantKeywordFieldMapper( return new ConstantKeywordFieldMapper(
name(), leafName(),
new ConstantKeywordFieldType(context.buildFullName(name()), value.getValue(), meta.getValue()) new ConstantKeywordFieldType(context.buildFullName(leafName()), value.getValue(), meta.getValue())
); );
} }
} }

View file

@ -290,16 +290,16 @@ public class CountedKeywordFieldMapper extends FieldMapper {
public FieldMapper build(MapperBuilderContext context) { public FieldMapper build(MapperBuilderContext context) {
BinaryFieldMapper countFieldMapper = new BinaryFieldMapper.Builder( BinaryFieldMapper countFieldMapper = new BinaryFieldMapper.Builder(
name() + COUNT_FIELD_NAME_SUFFIX, leafName() + COUNT_FIELD_NAME_SUFFIX,
context.isSourceSynthetic() context.isSourceSynthetic()
).docValues(true).build(context); ).docValues(true).build(context);
boolean isIndexed = indexed.getValue(); boolean isIndexed = indexed.getValue();
FieldType ft = isIndexed ? FIELD_TYPE_INDEXED : FIELD_TYPE_NOT_INDEXED; FieldType ft = isIndexed ? FIELD_TYPE_INDEXED : FIELD_TYPE_NOT_INDEXED;
return new CountedKeywordFieldMapper( return new CountedKeywordFieldMapper(
name(), leafName(),
ft, ft,
new CountedKeywordFieldType( new CountedKeywordFieldType(
context.buildFullName(name()), context.buildFullName(leafName()),
isIndexed, isIndexed,
false, false,
true, true,

View file

@ -158,7 +158,7 @@ public class UnsignedLongFieldMapper extends FieldMapper {
parseUnsignedLong(o); // confirm that null_value is a proper unsigned_long parseUnsignedLong(o); // confirm that null_value is a proper unsigned_long
return (o instanceof BytesRef) ? ((BytesRef) o).utf8ToString() : o.toString(); return (o instanceof BytesRef) ? ((BytesRef) o).utf8ToString() : o.toString();
} catch (Exception e) { } catch (Exception e) {
throw new MapperParsingException("Error parsing [null_value] on field [" + name() + "]: " + e.getMessage(), e); throw new MapperParsingException("Error parsing [null_value] on field [" + leafName() + "]: " + e.getMessage(), e);
} }
} }
@ -200,7 +200,7 @@ public class UnsignedLongFieldMapper extends FieldMapper {
dimension.setValue(true); dimension.setValue(true);
} }
UnsignedLongFieldType fieldType = new UnsignedLongFieldType( UnsignedLongFieldType fieldType = new UnsignedLongFieldType(
context.buildFullName(name()), context.buildFullName(leafName()),
indexed.getValue(), indexed.getValue(),
stored.getValue(), stored.getValue(),
hasDocValues.getValue(), hasDocValues.getValue(),
@ -211,7 +211,7 @@ public class UnsignedLongFieldMapper extends FieldMapper {
indexMode indexMode
); );
return new UnsignedLongFieldMapper( return new UnsignedLongFieldMapper(
name(), leafName(),
fieldType, fieldType,
multiFieldsBuilder.build(this, context), multiFieldsBuilder.build(this, context),
copyTo, copyTo,

View file

@ -112,14 +112,14 @@ public class VersionStringFieldMapper extends FieldMapper {
} }
private VersionStringFieldType buildFieldType(MapperBuilderContext context, FieldType fieldtype) { private VersionStringFieldType buildFieldType(MapperBuilderContext context, FieldType fieldtype) {
return new VersionStringFieldType(context.buildFullName(name()), fieldtype, meta.getValue()); return new VersionStringFieldType(context.buildFullName(leafName()), fieldtype, meta.getValue());
} }
@Override @Override
public VersionStringFieldMapper build(MapperBuilderContext context) { public VersionStringFieldMapper build(MapperBuilderContext context) {
FieldType fieldtype = new FieldType(Defaults.FIELD_TYPE); FieldType fieldtype = new FieldType(Defaults.FIELD_TYPE);
return new VersionStringFieldMapper( return new VersionStringFieldMapper(
name(), leafName(),
fieldtype, fieldtype,
buildFieldType(context, fieldtype), buildFieldType(context, fieldtype),
multiFieldsBuilder.build(this, context), multiFieldsBuilder.build(this, context),

View file

@ -173,7 +173,7 @@ public class GeoShapeWithDocValuesFieldMapper extends AbstractShapeGeometryField
GeometryFieldScript.Factory factory = scriptCompiler.compile(this.script.get(), GeometryFieldScript.CONTEXT); GeometryFieldScript.Factory factory = scriptCompiler.compile(this.script.get(), GeometryFieldScript.CONTEXT);
return factory == null return factory == null
? null ? null
: (lookup, ctx, doc, consumer) -> factory.newFactory(name(), script.get().getParams(), lookup, OnScriptError.FAIL) : (lookup, ctx, doc, consumer) -> factory.newFactory(leafName(), script.get().getParams(), lookup, OnScriptError.FAIL)
.newInstance(ctx) .newInstance(ctx)
.runForDoc(doc, consumer); .runForDoc(doc, consumer);
} }
@ -194,7 +194,7 @@ public class GeoShapeWithDocValuesFieldMapper extends AbstractShapeGeometryField
); );
GeoShapeParser parser = new GeoShapeParser(geometryParser, orientation.get().value()); GeoShapeParser parser = new GeoShapeParser(geometryParser, orientation.get().value());
GeoShapeWithDocValuesFieldType ft = new GeoShapeWithDocValuesFieldType( GeoShapeWithDocValuesFieldType ft = new GeoShapeWithDocValuesFieldType(
context.buildFullName(name()), context.buildFullName(leafName()),
indexed.get(), indexed.get(),
hasDocValues.get(), hasDocValues.get(),
stored.get(), stored.get(),
@ -206,7 +206,7 @@ public class GeoShapeWithDocValuesFieldMapper extends AbstractShapeGeometryField
); );
if (script.get() == null) { if (script.get() == null) {
return new GeoShapeWithDocValuesFieldMapper( return new GeoShapeWithDocValuesFieldMapper(
name(), leafName(),
ft, ft,
multiFieldsBuilder.build(this, context), multiFieldsBuilder.build(this, context),
copyTo, copyTo,
@ -216,7 +216,7 @@ public class GeoShapeWithDocValuesFieldMapper extends AbstractShapeGeometryField
); );
} }
return new GeoShapeWithDocValuesFieldMapper( return new GeoShapeWithDocValuesFieldMapper(
name(), leafName(),
ft, ft,
multiFieldsBuilder.build(this, context), multiFieldsBuilder.build(this, context),
copyTo, copyTo,

View file

@ -105,14 +105,14 @@ public class PointFieldMapper extends AbstractPointGeometryFieldMapper<Cartesian
); );
} }
CartesianPointParser parser = new CartesianPointParser( CartesianPointParser parser = new CartesianPointParser(
name(), leafName(),
p -> CartesianPoint.parsePoint(p, ignoreZValue.get().value()), p -> CartesianPoint.parsePoint(p, ignoreZValue.get().value()),
nullValue.get(), nullValue.get(),
ignoreZValue.get().value(), ignoreZValue.get().value(),
ignoreMalformed.get().value() ignoreMalformed.get().value()
); );
PointFieldType ft = new PointFieldType( PointFieldType ft = new PointFieldType(
context.buildFullName(name()), context.buildFullName(leafName()),
indexed.get(), indexed.get(),
stored.get(), stored.get(),
hasDocValues.get(), hasDocValues.get(),
@ -120,7 +120,7 @@ public class PointFieldMapper extends AbstractPointGeometryFieldMapper<Cartesian
nullValue.get(), nullValue.get(),
meta.get() meta.get()
); );
return new PointFieldMapper(name(), ft, multiFieldsBuilder.build(this, context), copyTo, parser, this); return new PointFieldMapper(leafName(), ft, multiFieldsBuilder.build(this, context), copyTo, parser, this);
} }
} }

View file

@ -118,14 +118,14 @@ public class ShapeFieldMapper extends AbstractShapeGeometryFieldMapper<Geometry>
); );
Parser<Geometry> parser = new ShapeParser(geometryParser); Parser<Geometry> parser = new ShapeParser(geometryParser);
ShapeFieldType ft = new ShapeFieldType( ShapeFieldType ft = new ShapeFieldType(
context.buildFullName(name()), context.buildFullName(leafName()),
indexed.get(), indexed.get(),
hasDocValues.get(), hasDocValues.get(),
orientation.get().value(), orientation.get().value(),
parser, parser,
meta.get() meta.get()
); );
return new ShapeFieldMapper(name(), ft, multiFieldsBuilder.build(this, context), copyTo, parser, this); return new ShapeFieldMapper(leafName(), ft, multiFieldsBuilder.build(this, context), copyTo, parser, this);
} }
} }

View file

@ -238,8 +238,14 @@ public class WildcardFieldMapper extends FieldMapper {
@Override @Override
public WildcardFieldMapper build(MapperBuilderContext context) { public WildcardFieldMapper build(MapperBuilderContext context) {
return new WildcardFieldMapper( return new WildcardFieldMapper(
name(), leafName(),
new WildcardFieldType(context.buildFullName(name()), nullValue.get(), ignoreAbove.get(), indexVersionCreated, meta.get()), new WildcardFieldType(
context.buildFullName(leafName()),
nullValue.get(),
ignoreAbove.get(),
indexVersionCreated,
meta.get()
),
ignoreAbove.get(), ignoreAbove.get(),
context.isSourceSynthetic(), context.isSourceSynthetic(),
multiFieldsBuilder.build(this, context), multiFieldsBuilder.build(this, context),