use of com.typesafe.config.ConfigValue in project play2-elasticsearch by cleverage.
the class IndexConfig method loadMappingFromConfig.
/**
* Load additional mappings from config entry "elasticsearch.index.mapping"
* @param indexName
*/
private void loadMappingFromConfig(String indexName) {
Configuration mappingConfig = (configuration.getConfig("elasticsearch." + indexName + ".mappings") == Option.apply((Configuration) null)) ? null : configuration.getConfig("elasticsearch." + indexName + ".mappings").get();
if (mappingConfig != null) {
Iterator<Tuple2<String, ConfigValue>> iter = mappingConfig.entrySet().iterator();
while (iter.hasNext()) {
Tuple2<String, ConfigValue> mapping = iter.next();
String indexType = mapping._1();
IndexQueryPath indexQueryPath = new IndexQueryPath(indexName, indexType);
if (mapping._2().unwrapped() instanceof String) {
indexMappings.put(indexQueryPath, (String) mapping._2().unwrapped());
} else {
try {
indexMappings.put(indexQueryPath, Json.toJson(mapping._2().unwrapped()).toString());
} catch (Exception e) {
Logger.warn("Incorrect value in elasticsearch.index.mappings", e);
}
}
}
}
}
Aggregations