Skip to content

DateHistogramAggregation - changing Interval to FixedInterval produces an invalid request #4839

@awelburn

Description

@awelburn

NEST/Elasticsearch.Net version: 7.8.1
Elasticsearch version: 7.8.0

Description of the problem including expected versus actual behavior:
Converting from 6.x to 7, using NEST.7xUpgradeAssistant (really helpful btw!)
When changing code from
.Interval(DateInterval.Day)
the comment on the Obsolete attribute implies that the equivalent call should be
.FixedInterval(DateInterval.Day)
but this seems to produce an invalid request? (showing only the aggs fragment):
"aggs": {"doccountbyday": {"date_histogram": {"field": "published","fixed_interval": "day"}}}
The Reason is
failed to parse setting [date_histogram.fixedInterval] with value [day] as a time value: unit is missing or unrecognized

I've figured out that the new code should be
.FixedInterval(new Time(1, TimeUnit.Day))
which does produce a valid request:
{"aggs":{"doccountbyday":{"date_histogram":{"field":"published","fixed_interval":"1d"}}}

Expected behavior
Either remove FixedInterval(DateInterval interval) - it's not a breaking change if it's already broken?!
or perform the conversion from DateInterval to Time within the method?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions