Skip to content

Conversation

@csoulios
Copy link
Contributor

Backports #69921 to 7.x

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. Finally, no rollup metadata exists in the global cluster state

csoulios and others added 3 commits March 18, 2021 17:45
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]>
@csoulios csoulios added :StorageEngine/Rollup Turn fine-grained time-based data into coarser-grained data backport labels Mar 22, 2021
@elasticmachine elasticmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Mar 22, 2021
@elasticmachine
Copy link
Collaborator

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();
Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor

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.

@csoulios csoulios requested a review from talevy March 22, 2021 14:48
@csoulios csoulios merged commit f8f8cbf into elastic:7.x Mar 22, 2021
@csoulios csoulios deleted the rollupv2-meta-refactor-7.x branch March 22, 2021 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport :StorageEngine/Rollup Turn fine-grained time-based data into coarser-grained data Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants