Skip to content

Commit

Permalink
Adding number of routing shards to index settings before passing into…
Browse files Browse the repository at this point in the history
… GetSettingsResponse

Signed-off-by: Sophia <tjdud6024@gmail.com>
  • Loading branch information
Sophia committed Jun 21, 2024
1 parent bcccedb commit 1b12a69
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Fix the computed max shards of cluster to avoid int overflow ([#14155](https://github.com/opensearch-project/OpenSearch/pull/14155))
- Fixed rest-high-level client searchTemplate & mtermVectors endpoints to have a leading slash ([#14465](https://github.com/opensearch-project/OpenSearch/pull/14465))
- Write shard level metadata blob when snapshotting searchable snapshot indexes ([#13190](https://github.com/opensearch-project/OpenSearch/pull/13190))
- Updated GET {index}/_settings to return `number_of_routing_shards` ([#14446](https://github.com/opensearch-project/OpenSearch/pull/14446))

### Security

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ setup:
settings:
number_of_shards: 3
number_of_replicas: 0
number_of_routing_shards: 4

---
"Get /_settings":
Expand All @@ -25,6 +26,7 @@ setup:
- match: { test_1.settings.index.number_of_replicas: "1"}
- match: { test_2.settings.index.number_of_shards: "3"}
- match: { test_2.settings.index.number_of_replicas: "0"}
- match: { test_2.settings.index.number_of_routing_shards: "4"}

---
"Get /{index}/_settings":
Expand Down Expand Up @@ -109,6 +111,7 @@ setup:
- match: { test_2.settings.index.number_of_shards: "3"}
- is_false: test_1.settings.index.number_of_replicas
- is_false: test_2.settings.index.number_of_replicas
- is_false: test_2.settings.index.number_of_routing_shards

---
"Get /_all/_settings/{name}":
Expand All @@ -122,6 +125,7 @@ setup:
- match: { test_2.settings.index.number_of_shards: "3"}
- is_false: test_1.settings.index.number_of_replicas
- is_false: test_2.settings.index.number_of_replicas
- is_false: test_2.settings.index.number_of_routing_shards


---
Expand All @@ -136,6 +140,7 @@ setup:
- match: { test_2.settings.index.number_of_shards: "3"}
- is_false: test_1.settings.index.number_of_replicas
- is_false: test_2.settings.index.number_of_replicas
- is_false: test_2.settings.index.number_of_routing_shards

---
"Get /index,index/_settings/{name}":
Expand All @@ -149,6 +154,7 @@ setup:
- match: { test_2.settings.index.number_of_shards: "3"}
- is_false: test_1.settings.index.number_of_replicas
- is_false: test_2.settings.index.number_of_replicas
- is_false: test_2.settings.index.number_of_routing_shards

---
"Get /index*/_settings/{name}":
Expand All @@ -161,6 +167,7 @@ setup:
- match: { test_2.settings.index.number_of_shards: "3"}
- is_false: test_1
- is_false: test_2.settings.index.number_of_replicas
- is_false: test_2.settings.index.number_of_routing_shards

---
"Get /_settings with local flag":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ protected void clusterManagerOperation(GetSettingsRequest request, ClusterState
indexSettings = indexSettings.filter(k -> Regex.simpleMatch(request.names(), k));
}

indexSettings = Settings.builder()
.put(indexSettings)
.put(IndexMetadata.INDEX_NUMBER_OF_ROUTING_SHARDS_SETTING.getKey(), indexMetadata.getRoutingNumShards())
.build();

indexToSettingsBuilder.put(concreteIndex.getName(), indexSettings);
if (request.includeDefaults()) {
Settings defaultSettings = settingsFilter.filter(indexScopedSettings.diff(indexSettings, Settings.EMPTY));
Expand Down

0 comments on commit 1b12a69

Please sign in to comment.