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

[BUG] Max aggregation result is defaulted 0 when there is no value from OpenSearch #1481

Open
tnguyen456 opened this issue Mar 14, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@tnguyen456
Copy link

What is the bug?

MaxAggregate has value as 0 when there is no record match or aggregated field has no values even though OpenSearch returns null

How can one reproduce the bug?

  • Create an index with a numeric field
  • Send aggregation request for the field
  • Since there is no document, the aggregation result is returned as null by OpenSearch but MaxAggregate from java-client has value as 0

What is the expected behavior?

Because value is defaulted to 0, it causes confusion to consumers as there is no way to tell whether 0 means no value or it's actually the max.

The expected behaviour should be returning the same value as OpenSearch

What is your host/environment?

OpenSearch 2.11
OpenSearch java client 2.14

@tnguyen456 tnguyen456 added bug Something isn't working untriaged labels Mar 14, 2025
@Xtansia Xtansia removed the untriaged label Mar 18, 2025
@Xtansia
Copy link
Collaborator

Xtansia commented Mar 18, 2025

Hi @tnguyen456,

Thanks for raising this issue, you definitely make a great point regarding differentiate missing values and true zero.
I'll need to do a little code archaeology to see if I can discern the original reasoning for the behaviour incase it is relevant.
As changing this behaviour would be a breaking change it may not be fixed until the 3.0.0 release, otherwise it would need a backwards compatible change that adds an additional getter (e.g. valueOrNull) with the correct behaviour and the old getter keeps the defaulting logic.

@Xtansia
Copy link
Collaborator

Xtansia commented Mar 18, 2025

And if you're interested in raising a PR to make such a fix yourself, it would be greatly welcomed.

@tnguyen456
Copy link
Author

Thanks @Xtansia for quick response.

We've implemented a kinda hacky workaround to override the deserializer to make it work for our cases.

But yeah, I agree that the proper fix should be like what you mentioned.

Probably I will try to come up with an PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants