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

Fix parsing of DateHistogramBucket key #131

Merged

Conversation

Xtansia
Copy link
Collaborator

@Xtansia Xtansia commented Jan 5, 2023

Description

Fixes the parsing of DateHistogramBuckets. The key was incorrectly being read as a long, when it should be a double. As can be seen here, the type parameter to KeyedBucket is double: https://github.com/opensearch-project/opensearch-net/blob/main/src/OpenSearch.Client/Aggregations/Bucket/DateHistogram/DateHistogramBucket.cs#LL34C51-L34C51
And response body from server looks like so:

{
    "_shards": {
        "failed": 0,
        "skipped": 0,
        "successful": 1,
        "total": 1
    },
    "aggregations": {
        "histogram#aggregation_ranges": {
            "buckets": [
                {
                    "doc_count": 1,
                    "key": 1672871085000.0,
                    "key_as_string": "2023-01-04T22:24:45.000Z"
                }
            ]
        }
    },
    "hits": {
        "hits": [],
        "max_score": null,
        "total": {
            "relation": "eq",
            "value": 1
        }
    },
    "timed_out": false,
    "took": 90
}

Issues Resolved

Fixes #130

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Yury-Fridlyand
Yury-Fridlyand previously approved these changes Jan 5, 2023
Copy link
Collaborator

@Yury-Fridlyand Yury-Fridlyand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you like adding query from #130 as a test?

@Xtansia
Copy link
Collaborator Author

Xtansia commented Jan 6, 2023

Would you like adding query from #130 as a test?

@Yury-Fridlyand Sure, would you rather a full integration test, or just unit testing the deserialization using a mocked client & fixed response?

@Yury-Fridlyand
Copy link
Collaborator

I see IT is better and easier to add.

@Yury-Fridlyand
Copy link
Collaborator

@Xtansia, perhaps you've lost the fix.
BTW, the test doesn't fail now, so it doesn't validate the fix.

Signed-off-by: Thomas Farr <tsfarr@amazon.com>
Signed-off-by: Thomas Farr <tsfarr@amazon.com>
Signed-off-by: Thomas Farr <tsfarr@amazon.com>
@Xtansia
Copy link
Collaborator Author

Xtansia commented Jan 6, 2023

@Yury-Fridlyand Was intentional as I was trying to get the reproduce working correctly, have got the reproduce and fix properly pushed now

@Yury-Fridlyand Yury-Fridlyand merged commit c98cdc0 into opensearch-project:main Jan 30, 2023
@Xtansia Xtansia deleted the fix/date-histogram-bucket branch January 30, 2023 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Parsing histogram interval failed
3 participants