-
Notifications
You must be signed in to change notification settings - Fork 25.6k
[7.x] [RollupV2] Move rollup metadata to field mappings #70647
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
Conversation
This PR moves field related rollup metadata from the index metadata to the field mapping metadata.
- date_histogram fields is moved to the timestamp field
(fields are fixed_interval or calendar_interval, time_zone)
- histogram fields are moved to the numeric field on which the the histogram is computed
(the field is named interval)
Also, the index uuid has been added to the index rollup settings as index.rollup.source.uuid
and index.rollup.source.name
The rest of the RollupMetadata has been removed and no rollup metadata exists in the global
cluster state.
Co-authored-by: Tal Levy <[email protected]>
|
Pinging @elastic/es-analytics-geo (Team:Analytics) |
|
|
||
| // Using the CreateIndexRequest class only to produce the transformation to the mappings map. | ||
| // Alternatively, we would have to copy-paste that part of the code. | ||
| Map<String, String> mappingAsMap = new CreateIndexRequest().mapping("_doc", mapping).mappings(); |
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.
@talevy Do you have any idea if there's a better way to create the mappings map?
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.
XContentHelper.convertToMap(XContentType.JSON.xContent(), Strings.toString(mapping), false)
should get the Map<String, Object>
or
XContentParser parser = null;
Map<String, String> mappingAsMap = null;
try {
parser = xContent.createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, Strings.toString(mapping))
mappingAsMap = parser.mapStrings();
} finally {
if (parser != null) {
parser.close();
}
}
I don't know if that is the best way, but the XContentParser#mapStrings looks promising. I wonder what the strategy for changing things between 7.x to 8.0 were here. that technique can likely be leveraged.
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.
I think in the piece of code that I shared a few weeks ago, I just re-used the CreateIndexRequest as you did. I felt it was the most readable at the time.
Backports #69921 to 7.x