-
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
Implement aggregate_metric field mapper #49830
Implement aggregate_metric field mapper #49830
Conversation
Pinging @elastic/es-analytics-geo (:Analytics/Rollup) |
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.
Thanks @csoulios.
I think the parse logic should be on the parse method not the parseCreateField method. The latter is used (I think) for dynamic mapping and I don't think this field allow that.
I am not sure the leniency in the parse logic. I would like to confirm it but if there is an error on one of the metrics (does not exist or have an incorrect value) we should stop generating the doc value if ignore malformed is true.
...n/rollup/src/main/java/org/elasticsearch/xpack/rollup/mapper/AggregateMetricFieldMapper.java
Outdated
Show resolved
Hide resolved
...n/rollup/src/main/java/org/elasticsearch/xpack/rollup/mapper/AggregateMetricFieldMapper.java
Outdated
Show resolved
Hide resolved
...n/rollup/src/main/java/org/elasticsearch/xpack/rollup/mapper/AggregateMetricFieldMapper.java
Outdated
Show resolved
Hide resolved
...n/rollup/src/main/java/org/elasticsearch/xpack/rollup/mapper/AggregateMetricFieldMapper.java
Outdated
Show resolved
Hide resolved
...n/rollup/src/main/java/org/elasticsearch/xpack/rollup/mapper/AggregateMetricFieldMapper.java
Outdated
Show resolved
Hide resolved
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.
Thanks @csoulios . I think you can use a dedicated module for this field mapper (see mapper-flattened
), no need to put it in the rollup module.
I left the other comments in the pr.
...n/rollup/src/main/java/org/elasticsearch/xpack/rollup/mapper/AggregateMetricFieldMapper.java
Outdated
Show resolved
Hide resolved
...n/rollup/src/main/java/org/elasticsearch/xpack/rollup/mapper/AggregateMetricFieldMapper.java
Outdated
Show resolved
Hide resolved
...n/rollup/src/main/java/org/elasticsearch/xpack/rollup/mapper/AggregateMetricFieldMapper.java
Outdated
Show resolved
Hide resolved
...n/rollup/src/main/java/org/elasticsearch/xpack/rollup/mapper/AggregateMetricFieldMapper.java
Outdated
Show resolved
Hide resolved
...n/rollup/src/main/java/org/elasticsearch/xpack/rollup/mapper/AggregateMetricFieldMapper.java
Outdated
Show resolved
Hide resolved
...n/rollup/src/main/java/org/elasticsearch/xpack/rollup/mapper/AggregateMetricFieldMapper.java
Outdated
Show resolved
Hide resolved
...n/rollup/src/main/java/org/elasticsearch/xpack/rollup/mapper/AggregateMetricFieldMapper.java
Outdated
Show resolved
Hide resolved
...n/rollup/src/main/java/org/elasticsearch/xpack/rollup/mapper/AggregateMetricFieldMapper.java
Outdated
Show resolved
Hide resolved
...n/rollup/src/main/java/org/elasticsearch/xpack/rollup/mapper/AggregateMetricFieldMapper.java
Outdated
Show resolved
Hide resolved
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.
Left a few comments! :)
Open question for discussion: since this is isolated functionality at the moment (can configure but not actually use the fields yet), should we potentially merge to a feature branch instead? Not sure of our plans to backport to 7x, but it would make a potential backport (or revert) easier too.
x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackSettings.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/elasticsearch/xpack/aggregatemetric/mapper/AggregateMetricFieldMapper.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/elasticsearch/xpack/aggregatemetric/mapper/AggregateMetricFieldMapper.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/elasticsearch/xpack/aggregatemetric/mapper/AggregateMetricFieldMapper.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/elasticsearch/xpack/aggregatemetric/mapper/AggregateMetricFieldMapper.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/elasticsearch/xpack/aggregatemetric/mapper/AggregateMetricFieldMapper.java
Outdated
Show resolved
Hide resolved
"] must contain all metrics " + metrics.value().toString()); | ||
} | ||
|
||
if (fieldType().hasDocValues()) { |
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 wonder if we should override setHasDocValues()
on the MappedFieldType so that it throws an exception if the user tries to disable doc values? Since we don't index anything and only store doc values, seems like we shouldn't let the user disable them?
Not sure, WDYT?
@elasticmachine run elasticsearch-ci/bwc |
Make parsing of malformed values stricter and ignore all field metrics even if a single metric is wrong
@elasticmachine run elasticsearch-ci/bwc |
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.
It looks good @csoulios, I left some comments regarding the tests. Can you also create a branch to merge this pr (can be in your fork) since we said that we'll need metrics aggregation support to publish in master ?
builder.store(false); | ||
builder.index(true); | ||
builder.docValues(true); | ||
builder.fieldType().setDocValuesType(DocValuesType.NUMERIC); |
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.
All these options are set by default in the NumberFieldMapper.Builder
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.
Fixed
...in/java/org/elasticsearch/xpack/aggregatemetric/mapper/AggregateDoubleMetricFieldMapper.java
Outdated
Show resolved
Hide resolved
public Query rangeQuery(Object lowerTerm, Object upperTerm, boolean includeLower, boolean includeUpper, QueryShardContext context) { | ||
return delegateFieldType().rangeQuery(lowerTerm, upperTerm, includeLower, includeUpper, context); | ||
} | ||
|
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.
you should also override isFieldWithinQuery
to handle range queries efficiently, fielddataBuilder
to handle aggregations and sort, and docValueFormat
to format double correctly.
...in/java/org/elasticsearch/xpack/aggregatemetric/mapper/AggregateDoubleMetricFieldMapper.java
Show resolved
Hide resolved
...in/java/org/elasticsearch/xpack/aggregatemetric/mapper/AggregateDoubleMetricFieldMapper.java
Outdated
Show resolved
Hide resolved
...test/java/org/elasticsearch/xpack/aggregatemetric/mapper/AggregateDoubleMetricTypeTests.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/Rollup.java
Outdated
Show resolved
Hide resolved
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 understand the idea now. It is looking good, just left a few comments for clarification.
...in/java/org/elasticsearch/xpack/aggregatemetric/mapper/AggregateDoubleMetricFieldMapper.java
Show resolved
Hide resolved
...in/java/org/elasticsearch/xpack/aggregatemetric/mapper/AggregateDoubleMetricFieldMapper.java
Show resolved
Hide resolved
...in/java/org/elasticsearch/xpack/aggregatemetric/mapper/AggregateDoubleMetricFieldMapper.java
Show resolved
Hide resolved
...in/java/org/elasticsearch/xpack/aggregatemetric/mapper/AggregateDoubleMetricFieldMapper.java
Show resolved
Hide resolved
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.
Thanks @csoulios. Easy to follow the mapping logic. I would only recommend to add a test that uses a parent object in the mapping so we make sure we are resolving the path correctly in the metric's docValues in that case.
@elasticmachine run elasticsearch-ci/1 |
Following the implementation of the aggregate_metric_double field mapper(#49830) we are implementing the Min, Max, ValueCount, Sum and Average aggregations on aggregate metrics. The code builds on the excellent work done for #42949 and uses the extensible ValuesSources infrastructure to wire up common metric aggregation on the aggregate_metric_double field type. This PR is part of the rollups v2 refactoring as described in meta issue #42720
This PR addresses part of #42720 creating a field mapper for storing pre-computed aggregate metrics such as
min
,max
,sum
andvalue_count