Elasticsearch 5: Fix handling of settings

Since Elasticsearch 5, Elasticsearch is now strict about settings. This
means that if you pass it a setting that it does not recognize,
Elasticsearch will throw an exception whereas previously it was lenient
in such situations. This commit removes passing all properties as
settings to Elasticsearch in favor of a special prefix es.setting for
which properties prefixed with this will be passed as settings to
Elasticsearch.
This commit is contained in:
Jason Tedor 2017-08-07 14:02:21 +02:00
Родитель a3ba64d5e2
Коммит 23163cc1ed
1 изменённых файлов: 8 добавлений и 1 удалений

Просмотреть файл

@ -94,7 +94,14 @@ public class ElasticsearchClient extends DB {
// if properties file contains elasticsearch user defined properties
// add it to the settings file (will overwrite the defaults).
settings.put(props);
for (final Entry<Object, Object> e : props.entrySet()) {
if (e.getKey() instanceof String) {
final String key = (String) e.getKey();
if (key.startsWith("es.setting.")) {
settings.put(key.substring("es.setting.".length()), e.getValue());
}
}
}
final String clusterName = settings.get("cluster.name");
System.err.println("Elasticsearch starting node = " + clusterName);
System.err.println("Elasticsearch node path.home = " + settings.get("path.home"));