@Override public Y build(BuilderContext context) { ContentPath.Type origPathType = context.path().pathType(); context.path().pathType(pathType); context.path().add(name); Map<String, Mapper> mappers = new HashMap<String, Mapper>(); for (Mapper.Builder builder : mappersBuilders) { Mapper mapper = builder.build(context); mappers.put(mapper.name(), mapper); } context.path().pathType(origPathType); context.path().remove(); ObjectMapper objectMapper = createMapper( name, context.path().fullPathAsText(name), enabled, nested, dynamic, pathType, mappers); objectMapper.includeInAllIfNotSet(includeInAll); return (Y) objectMapper; }
@Override public DateFieldMapper build(BuilderContext context) { fieldType.setOmitNorms(fieldType.omitNorms() && boost == 1.0f); if (!locale.equals(dateTimeFormatter.locale())) { dateTimeFormatter = new FormatDateTimeFormatter( dateTimeFormatter.format(), dateTimeFormatter.parser(), dateTimeFormatter.printer(), locale); } DateFieldMapper fieldMapper = new DateFieldMapper( buildNames(context), dateTimeFormatter, fieldType.numericPrecisionStep(), boost, fieldType, docValues, nullValue, timeUnit, ignoreMalformed(context), coerce(context), postingsProvider, docValuesProvider, similarity, normsLoading, fieldDataSettings, context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo); fieldMapper.includeInAll(includeInAll); return fieldMapper; }
@Override public SizeFieldMapper build(BuilderContext context) { return new SizeFieldMapper( enabledState, fieldType, postingsProvider, docValuesProvider, fieldDataSettings, context.indexSettings()); }
@Override public TypeFieldMapper build(BuilderContext context) { return new TypeFieldMapper( name, indexName, boost, fieldType, postingsProvider, docValuesProvider, fieldDataSettings, context.indexSettings()); }
@Override public ByteFieldMapper build(BuilderContext context) { fieldType.setOmitNorms(fieldType.omitNorms() && boost == 1.0f); ByteFieldMapper fieldMapper = new ByteFieldMapper( buildNames(context), precisionStep, boost, fieldType, nullValue, ignoreMalformed(context), postingsProvider, docValuesProvider, similarity, fieldDataSettings, context.indexSettings()); fieldMapper.includeInAll(includeInAll); return fieldMapper; }
@Override public AllFieldMapper build(BuilderContext context) { // In case the mapping overrides these fieldType.setIndexed(true); fieldType.setTokenized(true); return new AllFieldMapper( name, fieldType, indexAnalyzer, searchAnalyzer, enabled, autoBoost, postingsProvider, docValuesProvider, similarity, normsLoading, fieldDataSettings, context.indexSettings()); }
@Override public OntologyMapper build(BuilderContext context) { ContentPath.Type origPathType = context.path().pathType(); context.path().pathType(pathType); Map<String, FieldMapper<String>> fieldMappers = Maps.newHashMap(); context.path().add(name); if (propertyBuilders != null) { for (String property : propertyBuilders.keySet()) { StringFieldMapper sfm = propertyBuilders.get(property).build(context); fieldMappers.put(sfm.names().indexName(), sfm); } } // Initialise field mappers for the pre-defined fields for (FieldMappings mapping : ontologySettings.getFieldMappings()) { if (!fieldMappers.containsKey(context.path().fullPathAsText(mapping.getFieldName()))) { StringFieldMapper mapper = MapperBuilders.stringField(mapping.getFieldName()) .store(true) .index(true) .tokenized(!mapping.isUriField()) .build(context); fieldMappers.put(mapper.names().indexName(), mapper); } } context.path().remove(); // remove name context.path().pathType(origPathType); return new OntologyMapper( buildNames(context), fieldType, docValues, indexAnalyzer, searchAnalyzer, postingsProvider, docValuesProvider, similarity, fieldDataSettings, context.indexSettings(), new MultiFields.Builder().build(this, context), ontologySettings, fieldMappers, threadPool); }
@Override public IntegerFieldMapper build(BuilderContext context) { fieldType.setOmitNorms(fieldType.omitNorms() && boost == 1.0f); IntegerFieldMapper fieldMapper = new IntegerFieldMapper( buildNames(context), fieldType.numericPrecisionStep(), boost, fieldType, docValues, nullValue, ignoreMalformed(context), coerce(context), postingsProvider, docValuesProvider, similarity, normsLoading, fieldDataSettings, context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo); fieldMapper.includeInAll(includeInAll); return fieldMapper; }
@Override public AttachmentMapper build(BuilderContext context) { ContentPath.Type origPathType = context.path().pathType(); context.path().pathType(pathType); FieldMapper contentMapper; if (context.indexCreatedVersion().before(Version.V_2_0_0_beta1)) { // old behavior, we need the content to be indexed under the attachment field name if (contentBuilder instanceof FieldMapper.Builder == false) { throw new IllegalStateException("content field for attachment must be a field mapper"); } ((FieldMapper.Builder) contentBuilder).indexName(name); contentBuilder.name = name + "." + FieldNames.CONTENT; contentMapper = (FieldMapper) contentBuilder.build(context); context.path().add(name); } else { context.path().add(name); contentMapper = (FieldMapper) contentBuilder.build(context); } FieldMapper dateMapper = (FieldMapper) dateBuilder.build(context); FieldMapper authorMapper = (FieldMapper) authorBuilder.build(context); FieldMapper titleMapper = (FieldMapper) titleBuilder.build(context); FieldMapper nameMapper = (FieldMapper) nameBuilder.build(context); FieldMapper keywordsMapper = (FieldMapper) keywordsBuilder.build(context); FieldMapper contentTypeMapper = (FieldMapper) contentTypeBuilder.build(context); FieldMapper contentLength = (FieldMapper) contentLengthBuilder.build(context); FieldMapper language = (FieldMapper) languageBuilder.build(context); context.path().remove(); context.path().pathType(origPathType); if (defaultIndexedChars == null && context.indexSettings() != null) { defaultIndexedChars = context.indexSettings().getAsInt("index.mapping.attachment.indexed_chars", 100000); } if (defaultIndexedChars == null) { defaultIndexedChars = 100000; } if (ignoreErrors == null && context.indexSettings() != null) { ignoreErrors = context .indexSettings() .getAsBoolean("index.mapping.attachment.ignore_errors", Boolean.TRUE); } if (ignoreErrors == null) { ignoreErrors = Boolean.TRUE; } if (langDetect == null && context.indexSettings() != null) { langDetect = context .indexSettings() .getAsBoolean("index.mapping.attachment.detect_language", Boolean.FALSE); } if (langDetect == null) { langDetect = Boolean.FALSE; } MappedFieldType defaultFieldType = Defaults.FIELD_TYPE.clone(); if (this.fieldType.indexOptions() != IndexOptions.NONE && !this.fieldType.tokenized()) { defaultFieldType.setOmitNorms(true); defaultFieldType.setIndexOptions(IndexOptions.DOCS); if (!this.omitNormsSet && this.fieldType.boost() == 1.0F) { this.fieldType.setOmitNorms(true); } if (!this.indexOptionsSet) { this.fieldType.setIndexOptions(IndexOptions.DOCS); } } defaultFieldType.freeze(); this.setupFieldType(context); return new AttachmentMapper( name, fieldType, defaultFieldType, pathType, defaultIndexedChars, ignoreErrors, langDetect, contentMapper, dateMapper, titleMapper, nameMapper, authorMapper, keywordsMapper, contentTypeMapper, contentLength, language, context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo); }