use of org.janusgraph.diskstorage.es.IndexMappings in project janusgraph by JanusGraph.
the class ElasticSearchConfigTest method readMapping.
private IndexMappings readMapping(final ElasticMajorVersion version, final String mappingFilePath) throws IOException {
try (final InputStream inputStream = getClass().getResourceAsStream(mappingFilePath)) {
final IndexMappings mappings = objectMapper.readValue(inputStream, new TypeReference<IndexMappings>() {
});
if (version.getValue() < 5) {
// downgrade from text to string and keyword to string/not-analyzed
mappings.getMappings().values().stream().flatMap(mapping -> mapping.getProperties().entrySet().stream()).map(entry -> (Map<String, Object>) entry.getValue()).forEach(properties -> {
if (properties.get("type").equals("keyword")) {
properties.put("type", "string");
properties.put("index", "not_analyzed");
} else if (properties.get("type").equals("text")) {
properties.put("type", "string");
}
});
}
return mappings;
}
}
Aggregations