-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
Support synthetic source for aggregate_metric_double when ignore_malformed is used #108746
Support synthetic source for aggregate_metric_double when ignore_malformed is used #108746
Conversation
Pinging @elastic/es-storage-engine (Team:StorageEngine) |
Hi @lkts, I've created a changelog YAML for you. |
* Build a {@link BytesRef} wrapping a byte array containing an encoded form | ||
* of the passed XContentBuilder contents. | ||
*/ | ||
public static BytesRef encodeXContentBuilder(XContentBuilder builder) throws IOException { |
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 from #108417.
...in/java/org/elasticsearch/xpack/aggregatemetric/mapper/AggregateDoubleMetricFieldMapper.java
Outdated
Show resolved
Hide resolved
...in/java/org/elasticsearch/xpack/aggregatemetric/mapper/AggregateDoubleMetricFieldMapper.java
Outdated
Show resolved
Hide resolved
@@ -506,6 +572,9 @@ private Map<String, Object> randomAggregateMetric() { | |||
private void mapping(XContentBuilder b) throws IOException { | |||
String[] metrics = storedMetrics.stream().map(Metric::toString).toArray(String[]::new); | |||
b.field("type", CONTENT_TYPE).array(METRICS_FIELD, metrics).field(DEFAULT_METRIC, metrics[0]); | |||
if (malformedExample) { | |||
b.field(IGNORE_MALFORMED, true); | |||
} | |||
} | |||
|
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.
Can we add some more elaborate use cases, here or in yaml? We want to check for:
- Nested subfields within aggregate_metric_double
- Partial aggregate_metric_double (e.g. one metric ok, one invalid, two ok)
- Nested malformed fields, with other fields at the same level
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.
We do cover partials in malformedValue
. Nested is a good suggestion.
server/src/main/java/org/elasticsearch/common/xcontent/XContentHelper.java
Show resolved
Hide resolved
...in/java/org/elasticsearch/xpack/aggregatemetric/mapper/AggregateDoubleMetricFieldMapper.java
Outdated
Show resolved
Hide resolved
...in/java/org/elasticsearch/xpack/aggregatemetric/mapper/AggregateDoubleMetricFieldMapper.java
Show resolved
Hide resolved
@elasticmachine update branch |
metric: | ||
min: 18.2 | ||
max: 100 | ||
value_count: 50 |
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.
Nit: move value_count to the end, to make sure it's still tracked.
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.
Looks good. I left one question for verifying my understanding.
...in/java/org/elasticsearch/xpack/aggregatemetric/mapper/AggregateDoubleMetricFieldMapper.java
Show resolved
Hide resolved
// We don't use DrainingXContentParser since we don't want to go beyond current field | ||
malformedContentForSyntheticSource.copyCurrentStructure(context.parser()); | ||
} | ||
; |
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.
nit: unneeded semicolon?
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 PR adds synthetic source support for
aggregate_metric_double
field whenignore_malformed
is used.This PR introduces a pattern that will be reused in
ignore_malformed
support in synthetic source for other (complex object-like) fields. The pattern is to create a "shadow"XContentBuilder
that replicates all successfully parsed fields and values. In case of malformed data, everything remaining in the parser (inside the field) is copied over to the builder. As a result we get both successfully parsed pieces, malformed piece, and skipped pieces which is a full representation of user input and can go to synthetic source.Contributes to #90007.