Skip to content

Commit

Permalink
[ML] Add meta information to all ML indices (#37964)
Browse files Browse the repository at this point in the history
This change adds a _meta field storing the version in which
the index mappings were last updated to the 3 ML indices
that didn't previously have one:

- .ml-annotations
- .ml-meta
- .ml-notifications

All other ML indices already had such a _meta field.

This field will be useful if we ever need to automatically
update the index mappings during a future upgrade.
  • Loading branch information
droberts195 authored Jan 29, 2019
1 parent 218df30 commit 5f106a2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public static XContentBuilder docMapping() throws IOException {
XContentBuilder builder = jsonBuilder();
builder.startObject();
builder.startObject(TYPE);
ElasticsearchMappings.addMetaInformation(builder);
ElasticsearchMappings.addDefaultMapping(builder);
builder.startObject(ElasticsearchMappings.PROPERTIES)
.startObject(Calendar.ID.getPreferredName())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,11 @@ public static void createAnnotationsIndexIfNecessary(Settings settings, Client c
}

public static XContentBuilder annotationsMapping() throws IOException {
return jsonBuilder()
XContentBuilder builder = jsonBuilder()
.startObject()
.startObject(ElasticsearchMappings.DOC_TYPE)
.startObject(ElasticsearchMappings.PROPERTIES)
.startObject(ElasticsearchMappings.DOC_TYPE);
ElasticsearchMappings.addMetaInformation(builder);
builder.startObject(ElasticsearchMappings.PROPERTIES)
.startObject(Annotation.ANNOTATION.getPreferredName())
.field(ElasticsearchMappings.TYPE, ElasticsearchMappings.TEXT)
.endObject()
Expand Down Expand Up @@ -143,5 +144,6 @@ public static XContentBuilder annotationsMapping() throws IOException {
.endObject()
.endObject()
.endObject();
return builder;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -960,10 +960,10 @@ private static void addModelSizeStatsFieldsToMapping(XContentBuilder builder) th
}

public static XContentBuilder auditMessageMapping() throws IOException {
return jsonBuilder()
.startObject()
.startObject(AuditMessage.TYPE.getPreferredName())
.startObject(PROPERTIES)
XContentBuilder builder = jsonBuilder().startObject()
.startObject(AuditMessage.TYPE.getPreferredName());
addMetaInformation(builder);
builder.startObject(PROPERTIES)
.startObject(Job.ID.getPreferredName())
.field(TYPE, KEYWORD)
.endObject()
Expand All @@ -987,6 +987,7 @@ public static XContentBuilder auditMessageMapping() throws IOException {
.endObject()
.endObject()
.endObject();
return builder;
}

static String[] mappingRequiresUpdate(ClusterState state, String[] concreteIndices, Version minVersion) throws IOException {
Expand Down

0 comments on commit 5f106a2

Please sign in to comment.