Skip to content

Commit

Permalink
Make ml internal indices hidden
Browse files Browse the repository at this point in the history
  • Loading branch information
przemekwitek committed Feb 18, 2020
1 parent 0ebd61b commit a6cda62
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,13 @@ public Iterator<Setting<?>> settings() {
Setting.Property.Dynamic,
Setting.Property.IndexScope);

public static final String SETTING_INDEX_HIDDEN = "index.hidden";
/**
* Whether the index is considered hidden or not. A hidden index will not be resolved in
* normal wildcard searches unless explicitly allowed
*/
public static final Setting<Boolean> INDEX_HIDDEN_SETTING =
Setting.boolSetting("index.hidden", false, Property.IndexScope, Property.Final);
Setting.boolSetting(SETTING_INDEX_HIDDEN, false, Property.IndexScope, Property.Final);

/**
* an internal index format description, allowing us to find out if this index is upgraded or needs upgrading
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,6 @@ public class MetaDataCreateIndexService {
*/
private static final CharacterRunAutomaton DOT_INDICES_EXCLUSIONS = new CharacterRunAutomaton(Regex.simpleMatchToAutomaton(
".watch-history-*",
".ml-anomalies-*",
".ml-notifications-*",
".ml-annotations*",
".data-frame-notifications-*",
".transform-notifications-*"
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -618,9 +618,6 @@ public void testIndexNameExclusionsList() {
// this test case should be removed when DOT_INDICES_EXCLUSIONS is empty
List<String> excludedNames = Arrays.asList(
".watch-history-" + randomAlphaOfLength(5).toLowerCase(Locale.ROOT),
".ml-anomalies-" + randomAlphaOfLength(5).toLowerCase(Locale.ROOT),
".ml-notifications-" + randomAlphaOfLength(5).toLowerCase(Locale.ROOT),
".ml-annotations-" + randomAlphaOfLength(5).toLowerCase(Locale.ROOT),
".data-frame-notifications-" + randomAlphaOfLength(5).toLowerCase(Locale.ROOT),
".transform-notifications-" + randomAlphaOfLength(5).toLowerCase(Locale.ROOT)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,13 @@ public static void createAnnotationsIndexIfNecessary(Settings settings, Client c
// Create the annotations index if it doesn't exist already.
if (mlLookup.containsKey(INDEX_NAME) == false) {

CreateIndexRequest createIndexRequest = new CreateIndexRequest(INDEX_NAME);
createIndexRequest.mapping(annotationsMapping());
createIndexRequest.settings(Settings.builder()
.put(IndexMetaData.SETTING_AUTO_EXPAND_REPLICAS, "0-1")
.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, "1"));
CreateIndexRequest createIndexRequest =
new CreateIndexRequest(INDEX_NAME)
.mapping(annotationsMapping())
.settings(Settings.builder()
.put(IndexMetaData.SETTING_AUTO_EXPAND_REPLICAS, "0-1")
.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, "1")
.put(IndexMetaData.SETTING_INDEX_HIDDEN, true));

executeAsyncWithOrigin(client.threadPool().getThreadContext(), ML_ORIGIN, createIndexRequest,
ActionListener.<CreateIndexResponse>wrap(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"auto_expand_replicas" : "0-1",
"query" : {
"default_field" : "all_field_values"
}
},
"hidden": true
}
},
"mappings": ${xpack.ml.anomalydetection.results.mappings}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
],
"settings" : {
"index" : {
"auto_expand_replicas" : "0-1"
"auto_expand_replicas" : "0-1",
"hidden": true
}
},
"mappings" : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
"settings" : {
"index" : {
"number_of_shards" : "1",
"auto_expand_replicas" : "0-1"
}
"auto_expand_replicas" : "0-1",
"hidden": true
}
},
"mappings" : {
"_doc": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package org.elasticsearch.xpack.ml.integration;

import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.cluster.metadata.AliasMetaData;
import org.elasticsearch.common.collect.ImmutableOpenMap;
import org.elasticsearch.common.settings.Settings;
Expand Down Expand Up @@ -73,7 +74,10 @@ private boolean annotationsIndexExists() {
private int numberOfAnnotationsAliases() {
int count = 0;
ImmutableOpenMap<String, List<AliasMetaData>> aliases = client().admin().indices()
.prepareGetAliases(AnnotationIndex.READ_ALIAS_NAME, AnnotationIndex.WRITE_ALIAS_NAME).get().getAliases();
.prepareGetAliases(AnnotationIndex.READ_ALIAS_NAME, AnnotationIndex.WRITE_ALIAS_NAME)
.setIndicesOptions(IndicesOptions.LENIENT_EXPAND_OPEN_HIDDEN)
.get()
.getAliases();
if (aliases != null) {
for (ObjectObjectCursor<String, List<AliasMetaData>> entry : aliases) {
count += entry.value.size();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import org.elasticsearch.action.ActionFuture;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.cluster.node.DiscoveryNode;
Expand Down Expand Up @@ -489,6 +490,7 @@ private void run(String jobId, CheckedRunnable<Exception> disrupt) throws Except
// are what we expect them to be:
private static DataCounts getDataCountsFromIndex(String jobId) {
SearchResponse searchResponse = client().prepareSearch()
.setIndicesOptions(IndicesOptions.LENIENT_EXPAND_OPEN_HIDDEN)
.setQuery(QueryBuilders.idsQuery().addIds(DataCounts.documentId(jobId)))
.get();
if (searchResponse.getHits().getTotalHits().value != 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,8 @@
model_bytes: 10000000

- do:
indices.refresh: {}
indices.refresh:
index: .ml-anomalies-shared

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

- do:
indices.refresh: {}
indices.refresh:
index: .ml-state

- do:
catch: /status_exception/
Expand All @@ -953,7 +955,8 @@
key: value

- do:
indices.refresh: {}
indices.refresh:
index: .ml-state

- do:
catch: /status_exception/
Expand Down Expand Up @@ -990,7 +993,8 @@
}

- do:
indices.refresh: {}
indices.refresh:
index: .ml-anomalies-shared

- do:
catch: /status_exception/
Expand Down

0 comments on commit a6cda62

Please sign in to comment.