Skip to content

Commit a6cda62

Browse files
committed
Make ml internal indices hidden
1 parent 0ebd61b commit a6cda62

File tree

10 files changed

+31
-21
lines changed

10 files changed

+31
-21
lines changed

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -256,12 +256,13 @@ public Iterator<Setting<?>> settings() {
256256
Setting.Property.Dynamic,
257257
Setting.Property.IndexScope);
258258

259+
public static final String SETTING_INDEX_HIDDEN = "index.hidden";
259260
/**
260261
* Whether the index is considered hidden or not. A hidden index will not be resolved in
261262
* normal wildcard searches unless explicitly allowed
262263
*/
263264
public static final Setting<Boolean> INDEX_HIDDEN_SETTING =
264-
Setting.boolSetting("index.hidden", false, Property.IndexScope, Property.Final);
265+
Setting.boolSetting(SETTING_INDEX_HIDDEN, false, Property.IndexScope, Property.Final);
265266

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

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

-3
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,6 @@ public class MetaDataCreateIndexService {
119119
*/
120120
private static final CharacterRunAutomaton DOT_INDICES_EXCLUSIONS = new CharacterRunAutomaton(Regex.simpleMatchToAutomaton(
121121
".watch-history-*",
122-
".ml-anomalies-*",
123-
".ml-notifications-*",
124-
".ml-annotations*",
125122
".data-frame-notifications-*",
126123
".transform-notifications-*"
127124
));

server/src/test/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexServiceTests.java

-3
Original file line numberDiff line numberDiff line change
@@ -618,9 +618,6 @@ public void testIndexNameExclusionsList() {
618618
// this test case should be removed when DOT_INDICES_EXCLUSIONS is empty
619619
List<String> excludedNames = Arrays.asList(
620620
".watch-history-" + randomAlphaOfLength(5).toLowerCase(Locale.ROOT),
621-
".ml-anomalies-" + randomAlphaOfLength(5).toLowerCase(Locale.ROOT),
622-
".ml-notifications-" + randomAlphaOfLength(5).toLowerCase(Locale.ROOT),
623-
".ml-annotations-" + randomAlphaOfLength(5).toLowerCase(Locale.ROOT),
624621
".data-frame-notifications-" + randomAlphaOfLength(5).toLowerCase(Locale.ROOT),
625622
".transform-notifications-" + randomAlphaOfLength(5).toLowerCase(Locale.ROOT)
626623
);

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/annotations/AnnotationIndex.java

+7-5
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,13 @@ public static void createAnnotationsIndexIfNecessary(Settings settings, Client c
5959
// Create the annotations index if it doesn't exist already.
6060
if (mlLookup.containsKey(INDEX_NAME) == false) {
6161

62-
CreateIndexRequest createIndexRequest = new CreateIndexRequest(INDEX_NAME);
63-
createIndexRequest.mapping(annotationsMapping());
64-
createIndexRequest.settings(Settings.builder()
65-
.put(IndexMetaData.SETTING_AUTO_EXPAND_REPLICAS, "0-1")
66-
.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, "1"));
62+
CreateIndexRequest createIndexRequest =
63+
new CreateIndexRequest(INDEX_NAME)
64+
.mapping(annotationsMapping())
65+
.settings(Settings.builder()
66+
.put(IndexMetaData.SETTING_AUTO_EXPAND_REPLICAS, "0-1")
67+
.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, "1")
68+
.put(IndexMetaData.SETTING_INDEX_HIDDEN, true));
6769

6870
executeAsyncWithOrigin(client.threadPool().getThreadContext(), ML_ORIGIN, createIndexRequest,
6971
ActionListener.<CreateIndexResponse>wrap(

x-pack/plugin/core/src/main/resources/org/elasticsearch/xpack/core/ml/anomalydetection/results_index_template.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"auto_expand_replicas" : "0-1",
1313
"query" : {
1414
"default_field" : "all_field_values"
15-
}
15+
},
16+
"hidden": true
1617
}
1718
},
1819
"mappings": ${xpack.ml.anomalydetection.results.mappings}

x-pack/plugin/core/src/main/resources/org/elasticsearch/xpack/core/ml/anomalydetection/state_index_template.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
],
77
"settings" : {
88
"index" : {
9-
"auto_expand_replicas" : "0-1"
9+
"auto_expand_replicas" : "0-1",
10+
"hidden": true
1011
}
1112
},
1213
"mappings" : {

x-pack/plugin/core/src/main/resources/org/elasticsearch/xpack/core/ml/notifications_index_template.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
"settings" : {
88
"index" : {
99
"number_of_shards" : "1",
10-
"auto_expand_replicas" : "0-1"
11-
}
10+
"auto_expand_replicas" : "0-1",
11+
"hidden": true
12+
}
1213
},
1314
"mappings" : {
1415
"_doc": {

x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/AnnotationIndexIT.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
package org.elasticsearch.xpack.ml.integration;
77

88
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
9+
import org.elasticsearch.action.support.IndicesOptions;
910
import org.elasticsearch.cluster.metadata.AliasMetaData;
1011
import org.elasticsearch.common.collect.ImmutableOpenMap;
1112
import org.elasticsearch.common.settings.Settings;
@@ -73,7 +74,10 @@ private boolean annotationsIndexExists() {
7374
private int numberOfAnnotationsAliases() {
7475
int count = 0;
7576
ImmutableOpenMap<String, List<AliasMetaData>> aliases = client().admin().indices()
76-
.prepareGetAliases(AnnotationIndex.READ_ALIAS_NAME, AnnotationIndex.WRITE_ALIAS_NAME).get().getAliases();
77+
.prepareGetAliases(AnnotationIndex.READ_ALIAS_NAME, AnnotationIndex.WRITE_ALIAS_NAME)
78+
.setIndicesOptions(IndicesOptions.LENIENT_EXPAND_OPEN_HIDDEN)
79+
.get()
80+
.getAliases();
7781
if (aliases != null) {
7882
for (ObjectObjectCursor<String, List<AliasMetaData>> entry : aliases) {
7983
count += entry.value.size();

x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/MlDistributedFailureIT.java

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import org.elasticsearch.action.ActionFuture;
99
import org.elasticsearch.action.search.SearchResponse;
10+
import org.elasticsearch.action.support.IndicesOptions;
1011
import org.elasticsearch.cluster.ClusterState;
1112
import org.elasticsearch.cluster.metadata.MetaData;
1213
import org.elasticsearch.cluster.node.DiscoveryNode;
@@ -489,6 +490,7 @@ private void run(String jobId, CheckedRunnable<Exception> disrupt) throws Except
489490
// are what we expect them to be:
490491
private static DataCounts getDataCountsFromIndex(String jobId) {
491492
SearchResponse searchResponse = client().prepareSearch()
493+
.setIndicesOptions(IndicesOptions.LENIENT_EXPAND_OPEN_HIDDEN)
492494
.setQuery(QueryBuilders.idsQuery().addIds(DataCounts.documentId(jobId)))
493495
.get();
494496
if (searchResponse.getHits().getTotalHits().value != 1) {

x-pack/plugin/src/test/resources/rest-api-spec/test/ml/jobs_crud.yml

+8-4
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,8 @@
470470
model_bytes: 10000000
471471

472472
- do:
473-
indices.refresh: {}
473+
indices.refresh:
474+
index: .ml-anomalies-shared
474475

475476
- do:
476477
catch: /Invalid update value for analysis_limits[:] model_memory_limit cannot be decreased below current usage; current usage \[9mb\], update had \[5mb\]/
@@ -926,7 +927,8 @@
926927
key: value
927928

928929
- do:
929-
indices.refresh: {}
930+
indices.refresh:
931+
index: .ml-state
930932

931933
- do:
932934
catch: /status_exception/
@@ -953,7 +955,8 @@
953955
key: value
954956

955957
- do:
956-
indices.refresh: {}
958+
indices.refresh:
959+
index: .ml-state
957960

958961
- do:
959962
catch: /status_exception/
@@ -990,7 +993,8 @@
990993
}
991994

992995
- do:
993-
indices.refresh: {}
996+
indices.refresh:
997+
index: .ml-anomalies-shared
994998

995999
- do:
9961000
catch: /status_exception/

0 commit comments

Comments
 (0)