From 0b4bc0817e7267fc5b6a5dc0fdc2b56518a4b1a3 Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Mon, 11 Sep 2023 08:02:07 -0700 Subject: [PATCH] [Backport 2.10] Auto expand replicas (#554) * auto expand replicas (#539) Signed-off-by: Ashish Agrawal (cherry picked from commit 10039360a10f36c9696cc5750c8cece202d709ac) * Remove extra import Signed-off-by: Ashish Agrawal --------- Signed-off-by: Ashish Agrawal Co-authored-by: Ashish Agrawal Co-authored-by: Ashish Agrawal --- .../org/opensearch/securityanalytics/util/RuleIndices.java | 7 ++++++- 1 file changed, 6 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..ddb1f8860 100644 --- a/src/main/java/org/opensearch/securityanalytics/util/RuleIndices.java +++ b/src/main/java/org/opensearch/securityanalytics/util/RuleIndices.java @@ -5,6 +5,7 @@ package org.opensearch.securityanalytics.util; import java.util.Set; + import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.opensearch.OpenSearchStatusException; @@ -99,9 +100,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); } }