Christoph Büscher a6e3d356ed Change parsing of numeric to and from parameters in date_range aggregation (#25376)
Currently the `to` and `from` parameter in the `date_range` aggregation is not
parsed with the correct date field format from the mappings or the aggregation
if the argument is numeric, but always treated as a long value specifying
`epoch_millis`. This leads to problems e.g. when the format is `epoch_second`,
but the `to` and `from` are currently treated as millis.

With this change, we interpret these parameters according to the `format` of the target field.
If the `format` in the mappings is not compatible with numeric input values,
a compatible `format` (e.g. `epoch_millis`, `epoch_second`) must be specified in
the `date_range` aggregation itself, otherwise an error is thrown.

#Closes #17920
2017-07-18 09:45:28 +02:00

60 lines
1.9 KiB
Plaintext

[[breaking_60_aggregations_changes]]
=== Aggregations changes
==== Deprecated `pattern` element of include/exclude for terms aggregations has been removed
The `include` and `exclude` options of `terms` aggregations used to accept a
sub `pattern` object which has been removed. The pattern should now be directly
put as a value of the `include` and `exclude` fields. For instance, the below
`terms` aggregation:
[source,js]
--------------------------------------------------
POST /twitter/_search?size=0
{
"aggs" : {
"top_users" : {
"terms" : {
"field" : "user",
"include": {
"pattern": "foo.*"
},
"exclude": {
"pattern": ".*bar"
}
}
}
}
}
--------------------------------------------------
// CONSOLE
// TEST[skip: uses old unsupported syntax]
should be replaced with:
[source,js]
--------------------------------------------------
POST /twitter/_search?size=0
{
"aggs" : {
"top_users" : {
"terms" : {
"field" : "user",
"include": "foo.*",
"exclude": ".*bar"
}
}
}
}
--------------------------------------------------
// CONSOLE
// TEST[setup:twitter]
==== Numeric `to` and `from` parameters in `date_range` aggregation are interpreted according to `format` now
Numeric `to` and `from` parameters in `date_range` aggregations used to always be interpreted as `epoch_millis`,
making other numeric formats like `epoch_seconds` unusable for numeric input values.
Now we interpret these parameters according to the `format` of the target field.
If the `format` in the mappings is not compatible with the numeric input value, a compatible
`format` (e.g. `epoch_millis`, `epoch_second`) must be specified in the `date_range` aggregation, otherwise an error is thrown.