align with es221
This commit is contained in:
parent
e88e352ca5
commit
686e63f106
3 changed files with 21 additions and 11 deletions
|
@ -205,16 +205,16 @@ public abstract class AbstractBasicClient implements BasicClient {
|
||||||
|
|
||||||
protected abstract void closeClient(Settings settings) throws IOException;
|
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();
|
ensureClientIsPresent();
|
||||||
if (index == null) {
|
if (index == null) {
|
||||||
throw new IOException("no index name given");
|
throw new IllegalArgumentException("no index name given");
|
||||||
}
|
}
|
||||||
if (key == null) {
|
if (key == null) {
|
||||||
throw new IOException("no key given");
|
throw new IllegalArgumentException("no key given");
|
||||||
}
|
}
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
throw new IOException("no value given");
|
throw new IllegalArgumentException("no value given");
|
||||||
}
|
}
|
||||||
Settings.Builder updateSettingsBuilder = Settings.builder();
|
Settings.Builder updateSettingsBuilder = Settings.builder();
|
||||||
updateSettingsBuilder.put(key, value.toString());
|
updateSettingsBuilder.put(key, value.toString());
|
||||||
|
|
|
@ -13,7 +13,6 @@ import org.elasticsearch.action.admin.indices.refresh.RefreshRequest;
|
||||||
import org.elasticsearch.action.delete.DeleteRequest;
|
import org.elasticsearch.action.delete.DeleteRequest;
|
||||||
import org.elasticsearch.action.index.IndexRequest;
|
import org.elasticsearch.action.index.IndexRequest;
|
||||||
import org.elasticsearch.action.update.UpdateRequest;
|
import org.elasticsearch.action.update.UpdateRequest;
|
||||||
import org.elasticsearch.common.Strings;
|
|
||||||
import org.elasticsearch.common.bytes.BytesArray;
|
import org.elasticsearch.common.bytes.BytesArray;
|
||||||
import org.elasticsearch.common.bytes.BytesReference;
|
import org.elasticsearch.common.bytes.BytesReference;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
|
@ -92,18 +91,29 @@ public abstract class AbstractBulkClient extends AbstractBasicClient implements
|
||||||
new CreateIndexRequestBuilder(client, CreateIndexAction.INSTANCE)
|
new CreateIndexRequestBuilder(client, CreateIndexAction.INSTANCE)
|
||||||
.setIndex(index);
|
.setIndex(index);
|
||||||
if (indexDefinition.getSettings() != null) {
|
if (indexDefinition.getSettings() != null) {
|
||||||
indexDefinition.setSettings(Strings.toString(Settings.builder()
|
Settings settings = Settings.builder()
|
||||||
.loadFromSource(indexDefinition.getSettings())
|
.loadFromSource(indexDefinition.getSettings())
|
||||||
.put("index.number_of_shards", indexDefinition.getShardCount())
|
.put("index.number_of_shards", indexDefinition.getShardCount())
|
||||||
.put("index.number_of_replicas", 0) // always 0
|
.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 {
|
} else {
|
||||||
indexDefinition.setSettings(Strings.toString(Settings.builder()
|
Settings settings = Settings.builder()
|
||||||
.put("index.number_of_shards", indexDefinition.getShardCount())
|
.put("index.number_of_shards", indexDefinition.getShardCount())
|
||||||
.put("index.number_of_replicas", 0) // always 0
|
.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) {
|
if (indexDefinition.getMappings() != null) {
|
||||||
try {
|
try {
|
||||||
Map<String, Object> mappings = JsonXContent.jsonXContent.createParser(indexDefinition.getMappings()).mapOrdered();
|
Map<String, Object> mappings = JsonXContent.jsonXContent.createParser(indexDefinition.getMappings()).mapOrdered();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
group = org.xbib
|
group = org.xbib
|
||||||
name = elx
|
name = elx
|
||||||
version = 2.2.1.45
|
version = 2.2.1.46
|
||||||
|
|
||||||
gradle.wrapper.version = 6.6.1
|
gradle.wrapper.version = 6.6.1
|
||||||
xbib-metrics.version = 2.1.0
|
xbib-metrics.version = 2.1.0
|
||||||
|
|
Loading…
Reference in a new issue