diff --git a/elx-common/src/main/java/org/xbib/elx/common/AbstractBasicClient.java b/elx-common/src/main/java/org/xbib/elx/common/AbstractBasicClient.java index 0fb30dd..0135338 100644 --- a/elx-common/src/main/java/org/xbib/elx/common/AbstractBasicClient.java +++ b/elx-common/src/main/java/org/xbib/elx/common/AbstractBasicClient.java @@ -205,16 +205,16 @@ public abstract class AbstractBasicClient implements BasicClient { protected abstract void closeClient(Settings settings) throws IOException; - protected void updateIndexSetting(String index, String key, Object value, long timeout, TimeUnit timeUnit) throws IOException { + protected void updateIndexSetting(String index, String key, Object value, long timeout, TimeUnit timeUnit) { ensureClientIsPresent(); if (index == null) { - throw new IOException("no index name given"); + throw new IllegalArgumentException("no index name given"); } if (key == null) { - throw new IOException("no key given"); + throw new IllegalArgumentException("no key given"); } if (value == null) { - throw new IOException("no value given"); + throw new IllegalArgumentException("no value given"); } Settings.Builder updateSettingsBuilder = Settings.builder(); updateSettingsBuilder.put(key, value.toString()); diff --git a/elx-common/src/main/java/org/xbib/elx/common/AbstractBulkClient.java b/elx-common/src/main/java/org/xbib/elx/common/AbstractBulkClient.java index 3fcd849..c630ce4 100644 --- a/elx-common/src/main/java/org/xbib/elx/common/AbstractBulkClient.java +++ b/elx-common/src/main/java/org/xbib/elx/common/AbstractBulkClient.java @@ -13,7 +13,6 @@ import org.elasticsearch.action.admin.indices.refresh.RefreshRequest; import org.elasticsearch.action.delete.DeleteRequest; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.update.UpdateRequest; -import org.elasticsearch.common.Strings; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.settings.Settings; @@ -92,18 +91,29 @@ public abstract class AbstractBulkClient extends AbstractBasicClient implements new CreateIndexRequestBuilder(client, CreateIndexAction.INSTANCE) .setIndex(index); if (indexDefinition.getSettings() != null) { - indexDefinition.setSettings(Strings.toString(Settings.builder() + Settings settings = Settings.builder() .loadFromSource(indexDefinition.getSettings()) .put("index.number_of_shards", indexDefinition.getShardCount()) .put("index.number_of_replicas", 0) // always 0 - .build())); + .build(); + try { + createIndexRequestBuilder.setSettings(JsonXContent.contentBuilder() + .map(settings.getAsStructuredMap()).string()); + } catch (IOException e) { + logger.warn(e.getMessage(), e); + } } else { - indexDefinition.setSettings(Strings.toString(Settings.builder() + Settings settings = Settings.builder() .put("index.number_of_shards", indexDefinition.getShardCount()) .put("index.number_of_replicas", 0) // always 0 - .build())); + .build(); + try { + createIndexRequestBuilder.setSettings(JsonXContent.contentBuilder() + .map(settings.getAsStructuredMap()).string()); + } catch (IOException e) { + logger.warn(e.getMessage(), e); + } } - createIndexRequestBuilder.setSettings(indexDefinition.getSettings()); if (indexDefinition.getMappings() != null) { try { Map mappings = JsonXContent.jsonXContent.createParser(indexDefinition.getMappings()).mapOrdered(); diff --git a/gradle.properties b/gradle.properties index 2dd2a34..178e078 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ group = org.xbib name = elx -version = 2.2.1.45 +version = 2.2.1.46 gradle.wrapper.version = 6.6.1 xbib-metrics.version = 2.1.0