-
Notifications
You must be signed in to change notification settings - Fork 25k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[7.x][ML] Refactor ML mappings and templates into JSON resources (#51… #52353
[7.x][ML] Refactor ML mappings and templates into JSON resources (#51… #52353
Conversation
…stic#51765) ML mappings and index templates have so far been created programmatically. While this had its merits due to static typing, there is consensus it would be clear to maintain those in json files. In addition, we are going to adding ILM policies to these indices and the component for a plugin to register ILM policies is `IndexTemplateRegistry`. It expects the templates to be in resource json files. For the above reasons this commit refactors ML mappings and index templates into json resource files that are registered via `MlIndexTemplateRegistry`. Backport of elastic#51765
Pinging @elastic/ml-core (:ml) |
return mapping(MapperService.SINGLE_MAPPING_NAME); | ||
} | ||
|
||
public static String mapping(String mappingType) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In 7.x
we need to still handle 6.x indices that have doc
instead of _doc
as the mapping type for the config and results index.
@@ -1290,10 +170,11 @@ public static void addDocMappingIfMissing(String alias, | |||
IndexMetaData indexMetaData = state.metaData().index(indicesThatRequireAnUpdate[0]); | |||
String mappingType = indexMetaData.mapping().type(); | |||
|
|||
try (XContentBuilder mapping = mappingSupplier.apply(mappingType)) { | |||
try { | |||
String mapping = mappingSupplier.apply(mappingType); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is where we pass the mapping type to the mapping supplier method.
return resultsMapping(MapperService.SINGLE_MAPPING_NAME); | ||
} | ||
|
||
public static String resultsMapping(String mappingType) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In 7.x
we need to still handle 6.x indices that have doc
instead of _doc
as the mapping type for the config and results index.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…765)
ML mappings and index templates have so far been created
programmatically. While this had its merits due to static typing,
there is consensus it would be clear to maintain those in json files.
In addition, we are going to adding ILM policies to these indices
and the component for a plugin to register ILM policies is
IndexTemplateRegistry
. It expects the templates to be in resourcejson files.
For the above reasons this commit refactors ML mappings and index
templates into json resource files that are registered via
MlIndexTemplateRegistry
.Backport of #51765