From 890d2d9417c90ff81e2c7e19c03271ae89b009ba Mon Sep 17 00:00:00 2001 From: Ashish Agrawal Date: Thu, 7 Sep 2023 10:49:50 -0700 Subject: [PATCH] auto expand replicas (#539) Signed-off-by: Ashish Agrawal (cherry picked from commit 10039360a10f36c9696cc5750c8cece202d709ac) --- .../opensearch/securityanalytics/util/RuleIndices.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/opensearch/securityanalytics/util/RuleIndices.java b/src/main/java/org/opensearch/securityanalytics/util/RuleIndices.java index 6783c0bb1..e52c3135b 100644 --- a/src/main/java/org/opensearch/securityanalytics/util/RuleIndices.java +++ b/src/main/java/org/opensearch/securityanalytics/util/RuleIndices.java @@ -5,6 +5,8 @@ package org.opensearch.securityanalytics.util; import java.util.Set; + +import com.google.common.collect.ImmutableMap; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.opensearch.OpenSearchStatusException; @@ -99,9 +101,13 @@ public static String ruleMappings() throws IOException { public void initRuleIndex(ActionListener actionListener, boolean isPrepackaged) throws IOException { if (!ruleIndexExists(isPrepackaged)) { + Settings indexSettings = Settings.builder() + .put("index.hidden", true) + .put("index.auto_expand_replicas", "0-all") + .build(); CreateIndexRequest indexRequest = new CreateIndexRequest(getRuleIndex(isPrepackaged)) .mapping(ruleMappings()) - .settings(Settings.builder().put("index.hidden", true).build()); + .settings(indexSettings); client.admin().indices().create(indexRequest, actionListener); } }