Skip to content

Commit

Permalink
auto expand replica 0-2 on custom result index (opensearch-project#1362)
Browse files Browse the repository at this point in the history
Signed-off-by: Amit Galitzky <[email protected]>
  • Loading branch information
amitgalitz authored and jackiehanyang committed Jan 15, 2025
1 parent 061a183 commit 36b6758
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public abstract class IndexManagement<IndexType extends Enum<IndexType> & 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;
Expand Down Expand Up @@ -1396,6 +1397,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);
}
}
Expand Down

0 comments on commit 36b6758

Please sign in to comment.