Skip to content

Commit 82a0344

Browse files
authored
[ML] Adding a boolean "cleared" field to notifications index (elastic#74406)
This is to support elastic/kibana#18328. The "cleared" field will not be set by the backend. The mapping will exist so that the UI can set "cleared: true" for notifications that a user decides should no longer be displayed in the UI. The UI will treat "false" and "not present" identically for this field. This mapping will only apply for notifications written by version 7.14 and above. Notifications indices used by older versions of the product will not contain the mapping, so these notifications will not be clearable. Backport of elastic#74376
1 parent c49a066 commit 82a0344

File tree

6 files changed

+9
-6
lines changed

6 files changed

+9
-6
lines changed

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/notifications/NotificationsIndex.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
public final class NotificationsIndex {
1313

14-
public static final String NOTIFICATIONS_INDEX = ".ml-notifications-000001";
14+
public static final String NOTIFICATIONS_INDEX = ".ml-notifications-000002";
1515

1616
private static final String RESOURCE_PATH = "/org/elasticsearch/xpack/core/ml/";
1717
private static final String MAPPINGS_VERSION_VARIABLE = "xpack.ml.version";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"order" : 0,
33
"version" : ${xpack.ml.version.id},
44
"index_patterns" : [
5-
".ml-notifications-000001"
5+
".ml-notifications-000002"
66
],
77
"settings" : {
88
"index" : {

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
},
2828
"job_type": {
2929
"type": "keyword"
30+
},
31+
"cleared": {
32+
"type": "boolean"
3033
}
3134
}
3235
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"priority" : 2147483647,
33
"version" : ${xpack.ml.version.id},
44
"index_patterns" : [
5-
".ml-notifications-000001"
5+
".ml-notifications-000002"
66
],
77
"template" : {
88
"settings" : {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public void testCreatedWhenAfterOtherMlIndex() throws Exception {
6161
AnomalyDetectionAuditor auditor = new AnomalyDetectionAuditor(client(), getInstanceFromNode(ClusterService.class));
6262
auditor.info("whatever", "blah");
6363

64-
// Creating a document in the .ml-notifications-000001 index should cause .ml-annotations
64+
// Creating a document in the .ml-notifications-000002 index should cause .ml-annotations
6565
// to be created, as it should get created as soon as any other ML index exists
6666

6767
assertBusy(() -> {
@@ -78,7 +78,7 @@ public void testNotCreatedWhenAfterOtherMlIndexAndUpgradeInProgress() throws Exc
7878
AnomalyDetectionAuditor auditor = new AnomalyDetectionAuditor(client(), getInstanceFromNode(ClusterService.class));
7979
auditor.info("whatever", "blah");
8080

81-
// Creating a document in the .ml-notifications-000001 index would normally cause .ml-annotations
81+
// Creating a document in the .ml-notifications-000002 index would normally cause .ml-annotations
8282
// to be created, but in this case it shouldn't as we're doing an upgrade
8383

8484
assertBusy(() -> {

x-pack/qa/src/main/java/org/elasticsearch/xpack/test/rest/IndexMappingTemplateAsserter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public static void assertMlMappingsMatchTemplates(RestClient client) throws Exce
7575
assertComposableTemplateMatchesIndexMappings(client, ".ml-state", ".ml-state-000001", true, Collections.emptySet(), false);
7676
// Depending on the order Full Cluster restart tests are run there may not be an notifications index yet
7777
assertComposableTemplateMatchesIndexMappings(client,
78-
".ml-notifications-000001", ".ml-notifications-000001", true, notificationsIndexExceptions, false);
78+
".ml-notifications-000002", ".ml-notifications-000002", true, notificationsIndexExceptions, false);
7979
// .ml-annotations-6 does not use a template
8080
// .ml-anomalies-shared uses a template but will have dynamically updated mappings as new jobs are opened
8181

0 commit comments

Comments
 (0)