use of org.elasticsearch.index.mapper.DocumentMapper in project elasticsearch by elastic.
the class MetaDataMappingService method refreshIndexMapping.
private boolean refreshIndexMapping(IndexService indexService, IndexMetaData.Builder builder) {
boolean dirty = false;
String index = indexService.index().getName();
try {
List<String> updatedTypes = new ArrayList<>();
for (DocumentMapper mapper : indexService.mapperService().docMappers(true)) {
final String type = mapper.type();
if (!mapper.mappingSource().equals(builder.mapping(type).source())) {
updatedTypes.add(type);
}
}
// if a single type is not up-to-date, re-send everything
if (updatedTypes.isEmpty() == false) {
logger.warn("[{}] re-syncing mappings with cluster state because of types [{}]", index, updatedTypes);
dirty = true;
for (DocumentMapper mapper : indexService.mapperService().docMappers(true)) {
builder.putMapping(new MappingMetaData(mapper));
}
}
} catch (Exception e) {
logger.warn((Supplier<?>) () -> new ParameterizedMessage("[{}] failed to refresh-mapping in cluster state", index), e);
}
return dirty;
}
use of org.elasticsearch.index.mapper.DocumentMapper in project elasticsearch by elastic.
the class ChildrenAggregationBuilder method resolveConfig.
@Override
protected ValuesSourceConfig<ParentChild> resolveConfig(SearchContext context) {
ValuesSourceConfig<ParentChild> config = new ValuesSourceConfig<>(ValuesSourceType.BYTES);
DocumentMapper childDocMapper = context.mapperService().documentMapper(childType);
if (childDocMapper != null) {
ParentFieldMapper parentFieldMapper = childDocMapper.parentFieldMapper();
if (!parentFieldMapper.active()) {
throw new IllegalArgumentException("[children] no [_parent] field not configured that points to a parent type");
}
parentType = parentFieldMapper.type();
DocumentMapper parentDocMapper = context.mapperService().documentMapper(parentType);
if (parentDocMapper != null) {
parentFilter = parentDocMapper.typeFilter();
childFilter = childDocMapper.typeFilter();
ParentChildIndexFieldData parentChildIndexFieldData = context.fieldData().getForField(parentFieldMapper.fieldType());
config.fieldContext(new FieldContext(parentFieldMapper.fieldType().name(), parentChildIndexFieldData, parentFieldMapper.fieldType()));
} else {
config.unmapped(true);
}
} else {
config.unmapped(true);
}
return config;
}
use of org.elasticsearch.index.mapper.DocumentMapper in project elasticsearch-opennlp-plugin by spinscale.
the class OpenNlpMappingTest method testAnalyzedOpenNlpFieldMappings.
@Test
public void testAnalyzedOpenNlpFieldMappings() throws IOException {
String mapping = copyToStringFromClasspath("/test-mapping-keywordanalyzer.json");
DocumentMapper docMapper = mapperParser.parse(mapping);
String message = String.format("\"name\":{\"type\":\"string\",\"analyzer\":\"keyword\"}");
assertThat(docMapper.mappingSource().string(), containsString(message));
}
Aggregations