Skip to content

Commit cada2ea

Browse files
authored
Make min num replicas for enrich index configurable (#110686)
The min num replicas for the enrich index is currenty hardcoded to 0. We'd like to be able to override that value via a setting (currently not registered), like we already do for the downsample index.
1 parent 751629b commit cada2ea

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/EnrichPolicyRunner.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ public class EnrichPolicyRunner implements Runnable {
8585
static final String ENRICH_MATCH_FIELD_NAME = "enrich_match_field";
8686
static final String ENRICH_README_FIELD_NAME = "enrich_readme";
8787

88+
public static final String ENRICH_MIN_NUMBER_OF_REPLICAS_NAME = "enrich.min_number_of_replicas";
89+
8890
static final String ENRICH_INDEX_README_TEXT = "This index is managed by Elasticsearch and should not be modified in any way.";
8991

9092
private final String policyName;
@@ -137,7 +139,7 @@ public void run() {
137139
// This call does not set the origin to ensure that the user executing the policy has permission to access the source index
138140
client.admin().indices().getIndex(getIndexRequest, listener.delegateFailureAndWrap((l, getIndexResponse) -> {
139141
validateMappings(getIndexResponse);
140-
prepareAndCreateEnrichIndex(toMappings(getIndexResponse));
142+
prepareAndCreateEnrichIndex(toMappings(getIndexResponse), clusterService.getSettings());
141143
}));
142144
} catch (Exception e) {
143145
listener.onFailure(e);
@@ -434,10 +436,11 @@ static boolean isIndexableField(MapperService mapperService, String field, Strin
434436
}
435437
}
436438

437-
private void prepareAndCreateEnrichIndex(List<Map<String, Object>> mappings) {
439+
private void prepareAndCreateEnrichIndex(List<Map<String, Object>> mappings, Settings settings) {
440+
int numberOfReplicas = settings.getAsInt(ENRICH_MIN_NUMBER_OF_REPLICAS_NAME, 0);
438441
Settings enrichIndexSettings = Settings.builder()
439442
.put("index.number_of_shards", 1)
440-
.put("index.number_of_replicas", 0)
443+
.put("index.number_of_replicas", numberOfReplicas)
441444
// No changes will be made to an enrich index after policy execution, so need to enable automatic refresh interval:
442445
.put("index.refresh_interval", -1)
443446
// This disables eager global ordinals loading for all fields:

0 commit comments

Comments
 (0)