public void addDynamicMappingsUpdate(Mapping update) { if (dynamicMappingsUpdate == null) { dynamicMappingsUpdate = update; } else { dynamicMappingsUpdate = dynamicMappingsUpdate.merge(update, false); } }
private PutMappingRequestBuilder updateMappingRequest(Index index, String type, Mapping mappingUpdate, final TimeValue timeout) { if (type.equals(MapperService.DEFAULT_MAPPING)) { throw new IllegalArgumentException("_default_ mapping should not be updated"); } return client.preparePutMapping().setConcreteIndex(index).setType(type).setSource(mappingUpdate.toString(), XContentType.JSON) .setMasterNodeTimeout(timeout).setTimeout(timeout); }
/** * Generate a mapping update for the given root object mapper. */ public Mapping mappingUpdate(Mapper rootObjectMapper) { return new Mapping(indexCreated, (RootObjectMapper) rootObjectMapper, metadataMappers, meta); }
List<ObjectMapper> parentMappers = new ArrayList<>(); Mapper firstUpdate = dynamicMapperItr.next(); parentMappers.add(createUpdate(mapping.root(), splitAndValidatePath(firstUpdate.name()), 0, firstUpdate)); Mapper previousMapper = null; while (dynamicMapperItr.hasNext()) { assert parentMappers.size() == 1; return mapping.mappingUpdate(parentMappers.get(0));
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { return mapping.toXContent(builder, params); } }
public DocumentMapper(MapperService mapperService, Mapping mapping) { this.mapperService = mapperService; this.type = mapping.root().name(); this.typeText = new Text(this.type); final IndexSettings indexSettings = mapperService.getIndexSettings();
@SuppressWarnings({"unchecked"}) public <T extends MetadataFieldMapper> T metadataMapper(Class<T> type) { return mapping.metadataMapper(type); }
/** * Recursively update sub field types. */ public DocumentMapper updateFieldType(Map<String, MappedFieldType> fullNameToFieldType) { Mapping updated = this.mapping.updateFieldType(fullNameToFieldType); if (updated == this.mapping) { // no change return this; } assert updated == updated.updateFieldType(fullNameToFieldType) : "updateFieldType operation is not idempotent"; return new DocumentMapper(mapperService, updated); }
Mapping update = null; if (rootDynamicUpdate != null) { update = mapping.mappingUpdate(rootDynamicUpdate);
List<ObjectMapper> parentMappers = new ArrayList<>(); Mapper firstUpdate = dynamicMapperItr.next(); parentMappers.add(createUpdate(mapping.root(), splitAndValidatePath(firstUpdate.name()), 0, firstUpdate)); Mapper previousMapper = null; while (dynamicMapperItr.hasNext()) { assert parentMappers.size() == 1; return mapping.mappingUpdate(parentMappers.get(0));
@Override public String toString() { try { XContentBuilder builder = XContentFactory.jsonBuilder().startObject(); toXContent(builder, new ToXContent.MapParams(emptyMap())); return Strings.toString(builder.endObject()); } catch (IOException bogus) { throw new UncheckedIOException(bogus); } } }
MetadataFieldMapper[] metadataMappers = newMapper.mapping().metadataMappers; Collections.addAll(fieldMappers, metadataMappers); MapperUtils.collect(newMapper.mapping().root(), objectMappers, fieldMappers, fieldAliasMappers);
@SuppressWarnings({"unchecked"}) public <T extends MetadataFieldMapper> T metadataMapper(Class<T> type) { return mapping.metadataMapper(type); }
/** * Recursively update sub field types. */ public DocumentMapper updateFieldType(Map<String, MappedFieldType> fullNameToFieldType) { Mapping updated = this.mapping.updateFieldType(fullNameToFieldType); if (updated == this.mapping) { // no change return this; } assert updated == updated.updateFieldType(fullNameToFieldType) : "updateFieldType operation is not idempotent"; return new DocumentMapper(mapperService, updated); }
public DocumentMapper merge(Mapping mapping, boolean updateAllTypes) { Mapping merged = this.mapping.merge(mapping, updateAllTypes); return new DocumentMapper(mapperService, merged); }
public DocumentMapper build(MapperService mapperService) { Objects.requireNonNull(rootObjectMapper, "Mapper builder must have the root object mapper set"); Mapping mapping = new Mapping( mapperService.getIndexSettings().getIndexVersionCreated(), rootObjectMapper, metadataMappers.values().toArray(new MetadataFieldMapper[metadataMappers.values().size()]), meta); return new DocumentMapper(mapperService, mapping); } }
List<ObjectMapper> parentMappers = new ArrayList<>(); Mapper firstUpdate = dynamicMapperItr.next(); parentMappers.add(createUpdate(mapping.root(), splitAndValidatePath(firstUpdate.name()), 0, firstUpdate)); Mapper previousMapper = null; while (dynamicMapperItr.hasNext()) { assert parentMappers.size() == 1; return mapping.mappingUpdate(parentMappers.get(0));
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { return mapping.toXContent(builder, params); } }
private PutMappingRequestBuilder updateMappingRequest(String index, String type, Mapping mappingUpdate, final TimeValue timeout) { if (type.equals(MapperService.DEFAULT_MAPPING)) { throw new IllegalArgumentException("_default_ mapping should not be updated"); } return client.preparePutMapping(index).setType(type).setSource(mappingUpdate.toString()) .setMasterNodeTimeout(timeout).setTimeout(timeout); }
public DocumentMapper(MapperService mapperService, Mapping mapping) { this.mapperService = mapperService; this.type = mapping.root().name(); this.typeText = new Text(this.type); final IndexSettings indexSettings = mapperService.getIndexSettings();