@Override public ScaledFloatFieldMapper build(BuilderContext context) { if (scalingFactorSet == false) { throw new IllegalArgumentException("Field [" + name + "] misses required parameter [scaling_factor]"); } setupFieldType(context); return new ScaledFloatFieldMapper(name, fieldType, defaultFieldType, ignoreMalformed(context), coerce(context), includeInAll, context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo); } }
@Override public Y build(BuilderContext context) { context.path().add(name); Map<String, Mapper> mappers = new HashMap<>(); for (Mapper.Builder builder : mappersBuilders) { Mapper mapper = builder.build(context); Mapper existing = mappers.get(mapper.simpleName()); if (existing != null) { mapper = existing.merge(mapper, false); } mappers.put(mapper.simpleName(), mapper); } context.path().remove(); ObjectMapper objectMapper = createMapper(name, context.path().pathAsText(name), enabled, nested, dynamic, includeInAll, mappers, context.indexSettings()); return (Y) objectMapper; }
if (context.indexCreatedVersion().onOrAfter(Version.V_6_4_0)) { if (fieldType.indexOptions() == IndexOptions.DOCS_AND_FREQS) { prefixMapper = new PrefixFieldMapper(prefixFieldType, context.indexSettings()); context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
MappedFieldType failIfFieldMappingNotFound(String name, MappedFieldType fieldMapping) { if (fieldMapping != null || allowUnmappedFields) { return fieldMapping; } else if (mapUnmappedFieldAsString) { TextFieldMapper.Builder builder = new TextFieldMapper.Builder(name); return builder.build(new Mapper.BuilderContext(indexSettings.getSettings(), new ContentPath(1))).fieldType(); } else { throw new QueryShardException(this, "No field mapping can be found for the field with name [{}]", name); } }
public FieldAliasMapper build(BuilderContext context) { String fullName = context.path().pathAsText(name); return new FieldAliasMapper(name, fullName, path); } }
@Override public MetadataFieldMapper getDefault(MappedFieldType fieldType, ParserContext context) { final Settings indexSettings = context.mapperService().getIndexSettings().getSettings(); if (fieldType != null) { return new AllFieldMapper(indexSettings, fieldType); } else { return parse(NAME, Collections.emptyMap(), context) .build(new BuilderContext(indexSettings, new ContentPath(1))); } } }
@Override public MetadataFieldMapper getDefault(MappedFieldType fieldType, ParserContext context) { final Settings indexSettings = context.mapperService().getIndexSettings().getSettings(); if (fieldType != null) { return new FieldNamesFieldMapper(indexSettings, fieldType); } else { return parse(NAME, Collections.emptyMap(), context) .build(new BuilderContext(indexSettings, new ContentPath(1))); } } }
public Y build(Mapper.BuilderContext context) { // version 5.0 cuts over to LatLonPoint and no longer indexes geohash, or lat/lon separately if (context.indexCreatedVersion().before(LatLonPointFieldMapper.LAT_LON_FIELD_VERSION)) { return buildLegacy(context); } return build(context, name, fieldType, defaultFieldType, context.indexSettings(), null, null, null, multiFieldsBuilder.build(this, context), ignoreMalformed(context), copyTo); }
@Override public LegacyTokenCountFieldMapper build(BuilderContext context) { if (context.indexCreatedVersion().onOrAfter(Version.V_5_0_0_alpha2)) { throw new IllegalStateException("Cannot use legacy numeric types after 5.0"); } setupFieldType(context); return new LegacyTokenCountFieldMapper(name, fieldType, defaultFieldType, ignoreMalformed(context), coerce(context), includeInAll, context.indexSettings(), analyzer, multiFieldsBuilder.build(this, context), copyTo); }
@Override public LegacyIpFieldMapper build(BuilderContext context) { if (context.indexCreatedVersion().onOrAfter(Version.V_5_0_0_alpha2)) { throw new IllegalStateException("Cannot use legacy numeric types after 5.0"); } setupFieldType(context); return new LegacyIpFieldMapper(name, fieldType, defaultFieldType, ignoreMalformed(context), coerce(context), includeInAll, context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo); }
@Override public MetadataFieldMapper getDefault(MappedFieldType fieldType, ParserContext context) { final Settings indexSettings = context.mapperService().getIndexSettings().getSettings(); final String typeName = context.type(); KeywordFieldMapper parentJoinField = createParentJoinFieldMapper(typeName, new BuilderContext(indexSettings, new ContentPath(0))); MappedFieldType childJoinFieldType = new ParentFieldType(Defaults.FIELD_TYPE, typeName); childJoinFieldType.setName(ParentFieldMapper.NAME); return new ParentFieldMapper(parentJoinField, childJoinFieldType, null, indexSettings); } }
static RangeFieldMapper createExtractedRangeFieldBuilder(String name, RangeType rangeType, BuilderContext context) { RangeFieldMapper.Builder builder = new RangeFieldMapper.Builder(name, rangeType, context.indexCreatedVersion()); // For now no doc values, because in processQuery(...) only the Lucene range fields get added: builder.docValues(false); return builder.build(context); }
MappedFieldType failIfFieldMappingNotFound(String name, MappedFieldType fieldMapping) { if (fieldMapping != null || allowUnmappedFields) { return fieldMapping; } else if (mapUnmappedFieldAsString) { TextFieldMapper.Builder builder = new TextFieldMapper.Builder(name); return builder.build(new Mapper.BuilderContext(indexSettings.getSettings(), new ContentPath(1))).fieldType(); } else { throw new QueryShardException(this, "No field mapping can be found for the field with name [{}]", name); } }
@Override public MetadataFieldMapper getDefault(MappedFieldType fieldType, ParserContext context) { final Settings indexSettings = context.mapperService().getIndexSettings().getSettings(); if (fieldType != null) { return new RoutingFieldMapper(indexSettings, fieldType); } else { return parse(NAME, Collections.emptyMap(), context) .build(new BuilderContext(indexSettings, new ContentPath(1))); } } }
@Override public MetadataFieldMapper getDefault(MappedFieldType fieldType, ParserContext context) { final Settings indexSettings = context.mapperService().getIndexSettings().getSettings(); if (fieldType != null) { return new FieldNamesFieldMapper(indexSettings, fieldType); } else { return parse(NAME, Collections.emptyMap(), context) .build(new BuilderContext(indexSettings, new ContentPath(1))); } } }
static RangeFieldMapper createExtractedRangeFieldBuilder(String name, RangeType rangeType, BuilderContext context) { RangeFieldMapper.Builder builder = new RangeFieldMapper.Builder(name, rangeType, context.indexCreatedVersion()); // For now no doc values, because in processQuery(...) only the Lucene range fields get added: builder.docValues(false); return builder.build(context); }
@Override public MetadataFieldMapper getDefault(MappedFieldType fieldType, ParserContext context) { final Settings indexSettings = context.mapperService().getIndexSettings().getSettings(); if (fieldType != null) { return new RoutingFieldMapper(indexSettings, fieldType); } else { return parse(NAME, Collections.emptyMap(), context) .build(new BuilderContext(indexSettings, new ContentPath(1))); } } }
@Override public BinaryFieldMapper build(BuilderContext context) { setupFieldType(context); ((BinaryFieldType)fieldType).setTryUncompressing(context.indexCreatedVersion().before(Version.V_2_0_0_beta1)); return new BinaryFieldMapper(name, fieldType, defaultFieldType, context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo); } }
@Override public UidFieldMapper build(BuilderContext context) { setupFieldType(context); fieldType.setHasDocValues(context.indexCreatedVersion().before(Version.V_2_0_0_beta1)); return new UidFieldMapper(fieldType, defaultFieldType, context.indexSettings()); } }
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); }