ALX_DM
(ALX DM)
June 28, 2022, 5:19pm
1
In the new elasticsearch-java api client, is it possible to update a specific index setting by a key-value pair?
Say, you have these keys:
static final String NUMBER_OF_REPLICAS_KEY = "index.number_of_replicas";
static final String REFRESH_INTERVAL_KEY = "index.refresh_interval";
Then you create something like
key = REFRESH_INTERVAL_KEY
value = 1200
It seems not possible with the below code
PutIndicesSettingsRequest request = PutIndicesSettingsRequest.of(b -> b.index(indexName));
final Map<String, Object> map = new HashMap<>();
map.put(key, value);
Then call
client.indices().putSettings(...)
Is it possible?
RabBit_BR
(andre.coelho)
June 28, 2022, 5:42pm
2
Hi @ALX_DM
One way I know is the one below. Using a Map I don't know if it's possible.
IndexSettings indexSettings = IndexSettings.of(is -> is.numberOfReplicas("2").refreshInterval(Time.of(t -> t.time("1s"))));
PutIndicesSettingsRequest request = PutIndicesSettingsRequest.of(b -> b.index("idx_name").settings(indexSettings));
var response = ClientUtils.getClient().indices().putSettings(request);
ALX_DM
(ALX DM)
June 28, 2022, 10:25pm
3
@RabBit_BR
I see.
HLRC can do it, but the new es api client cannot for now. Got it
system
(system)
Closed
July 26, 2022, 10:25pm
4
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.