Skip to content
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

Date histrogram aggregation response class #8114

Open
RolfDeVries opened this issue Apr 10, 2024 · 2 comments
Open

Date histrogram aggregation response class #8114

RolfDeVries opened this issue Apr 10, 2024 · 2 comments

Comments

@RolfDeVries
Copy link

Elastic.Clients.Elasticsearch version:
8.13.5

Elasticsearch version:
N/A

.NET runtime version:
.Net 8.0

Operating system version:
N/A

Description of the problem including expected versus actual behavior:
I'm upgrading from NEST 7.latest to the new Elastic.Clients.Elasticsearch version.
And I'm missing some features that are not yet supported

Steps to reproduce:

  1. Create code to call the search API with a date histogram in it

  2. Trying to parse the response of the Aggregations in the Search Api:

            var bucket = agg as DateHistogramAggregate;
            return bucket?.Buckets.NotNull()
                   .ToDictionary(s => s.Date, s => s.DocCount)
    

Expected behavior
In the NEST 7 version, the properties Date existed in the buckets of the aggregate
In the Elastic.Client.Elasticsearch 8 these field is missing, please add this back

Provide ConnectionSettings (if relevant):

Provide DebugInformation (if relevant):

@flobernd
Copy link
Member

Hi @RolfDeVries,

for now you could try the following workaround:

var histogram = searchResponse.Aggregations?.GetDateHistogram("aggregation-name");
var dict = histogram?.Buckets.ToDictionary(k => DateTimeOffset.FromUnixTimeMilliseconds(k.Key).Date, v => v.DocCount);

It definitely makes sense to simplify access to the date.

There are probably more places where date values are generated as long instead of DateTime. I will do some research to see if it would be desired to generate DateTime in all of these places to improve usability.

@RolfDeVries
Copy link
Author

Thanks, the workaround will do for now. But I expect more places indeed.
This would be very much appreciated by many developers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants