From 240d42d39796c80cccf17c2acfba2270fbbca8f5 Mon Sep 17 00:00:00 2001 From: Sophia Date: Tue, 18 Jun 2024 22:21:06 -0500 Subject: [PATCH] Adding number of routing shards to index settings before passing into GetSettingsResponse Signed-off-by: Sophia --- CHANGELOG.md | 1 + .../rest-api-spec/test/indices.get_settings/10_basic.yml | 7 +++++++ .../indices/settings/get/TransportGetSettingsAction.java | 5 +++++ 3 files changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 41d9c4f4f3905..6cc52a6d42045 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_settings/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_settings/10_basic.yml index a50be32e82c6a..0b93f4caf7e3c 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_settings/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_settings/10_basic.yml @@ -14,6 +14,7 @@ setup: settings: number_of_shards: 3 number_of_replicas: 0 + number_of_routing_shards: 6 --- "Get /_settings": @@ -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: "6"} --- "Get /{index}/_settings": @@ -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}": @@ -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 --- @@ -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}": @@ -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}": @@ -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": diff --git a/server/src/main/java/org/opensearch/action/admin/indices/settings/get/TransportGetSettingsAction.java b/server/src/main/java/org/opensearch/action/admin/indices/settings/get/TransportGetSettingsAction.java index d8f2180208b18..9d6807176e6fe 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/settings/get/TransportGetSettingsAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/settings/get/TransportGetSettingsAction.java @@ -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));