Skip to content

Commit 587e12a

Browse files
authored
Allow dynamic updates for index.hidden setting (#52772)
This commit changes the `index.hidden` setting from being final to a dynamic setting. While the setting being final allows for easier reasoning about an index, making this setting update-able has more benefits in that we can upgrade existing indices to be hidden and it will enable future features that would dynamically make indices hidden.
1 parent 97f8f4a commit 587e12a

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

server/src/main/java/org/elasticsearch/cluster/metadata/IndexMetaData.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ public Iterator<Setting<?>> settings() {
262262
* normal wildcard searches unless explicitly allowed
263263
*/
264264
public static final Setting<Boolean> INDEX_HIDDEN_SETTING =
265-
Setting.boolSetting(SETTING_INDEX_HIDDEN, false, Property.IndexScope, Property.Final);
265+
Setting.boolSetting(SETTING_INDEX_HIDDEN, false, Property.Dynamic, Property.IndexScope);
266266

267267
/**
268268
* an internal index format description, allowing us to find out if this index is upgraded or needs upgrading

server/src/test/java/org/elasticsearch/index/HiddenIndexIT.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,15 @@ public void testHiddenIndexSearch() {
7777
.get();
7878
matchedHidden = Arrays.stream(searchResponse.getHits().getHits()).anyMatch(hit -> ".hidden-index".equals(hit.getIndex()));
7979
assertTrue(matchedHidden);
80+
81+
// make index not hidden
82+
assertAcked(client().admin().indices().prepareUpdateSettings("hidden-index")
83+
.setSettings(Settings.builder().put("index.hidden", false).build())
84+
.get());
85+
searchResponse =
86+
client().prepareSearch(randomFrom("*", "_all", "h*", "*index")).setSize(1000).setQuery(QueryBuilders.matchAllQuery()).get();
87+
matchedHidden = Arrays.stream(searchResponse.getHits().getHits()).anyMatch(hit -> "hidden-index".equals(hit.getIndex()));
88+
assertTrue(matchedHidden);
8089
}
8190

8291
public void testGlobalTemplatesDoNotApply() {

x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportResumeFollowAction.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ static String[] extractLeaderShardHistoryUUIDs(Map<String, String> ccrIndexMetaD
364364
IndexMetaData.INDEX_BLOCKS_READ_ONLY_ALLOW_DELETE_SETTING,
365365
IndexMetaData.INDEX_PRIORITY_SETTING,
366366
IndexMetaData.SETTING_WAIT_FOR_ACTIVE_SHARDS,
367+
IndexMetaData.INDEX_HIDDEN_SETTING,
367368
EnableAllocationDecider.INDEX_ROUTING_REBALANCE_ENABLE_SETTING,
368369
EnableAllocationDecider.INDEX_ROUTING_ALLOCATION_ENABLE_SETTING,
369370
ShardsLimitAllocationDecider.INDEX_TOTAL_SHARDS_PER_NODE_SETTING,

0 commit comments

Comments
 (0)