From 5ec87b25de9dffa5327800e827a79685b7192f2d Mon Sep 17 00:00:00 2001 From: Amit Galitzky Date: Tue, 12 Nov 2024 14:57:13 -0800 Subject: [PATCH] auto expand replica 0-2 on custom result index (#1362) Signed-off-by: Amit Galitzky --- .../opensearch/timeseries/indices/IndexManagement.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/org/opensearch/timeseries/indices/IndexManagement.java b/src/main/java/org/opensearch/timeseries/indices/IndexManagement.java index da116b8a7..6e47c8838 100644 --- a/src/main/java/org/opensearch/timeseries/indices/IndexManagement.java +++ b/src/main/java/org/opensearch/timeseries/indices/IndexManagement.java @@ -103,6 +103,7 @@ public abstract class IndexManagement & TimeSe public static final String META = "_meta"; public static final String SCHEMA_VERSION = "schema_version"; + public static final String customResultIndexAutoExpandReplica = "0-2"; protected ClusterService clusterService; protected final Client client; protected final AdminClient adminClient; @@ -1349,6 +1350,13 @@ protected void initResultIndexDirectly( if (defaultResultIndex) { adminClient.indices().create(request, markMappingUpToDate(resultIndex, actionListener)); } else { + request + .settings( + Settings + .builder() + // Support up to 2 replicas at least + .put(IndexMetadata.SETTING_AUTO_EXPAND_REPLICAS, customResultIndexAutoExpandReplica) + ); adminClient.indices().create(request, actionListener); } }