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

Typed keys in aggregation results cannot be switched off #741

Open
fs-chris opened this issue Nov 23, 2023 · 4 comments · May be fixed by #1296
Open

Typed keys in aggregation results cannot be switched off #741

fs-chris opened this issue Nov 23, 2023 · 4 comments · May be fixed by #1296
Labels
enhancement New feature or request

Comments

@fs-chris
Copy link
Contributor

fs-chris commented Nov 23, 2023

What is the bug?

The client always adds a type prefix to aggregation keys in responses which breaks compatibility with other clients or with frontend applications that directly work on aggregation responses.

This is a breaking change compared to other clients' behavior.

The Elasticsearch client API has a switch for turning off that behavior and thus returning compatible results.
See Serializing aggregations and suggestions without typed keys

How can one reproduce the bug?

Each aggregation result contains aggregation names combined as [type]#[name]

What is the expected behavior?

There should be a compatibility setting that allows returning aggregation names without type prefix like the one provided by Elasticsearch.

What is your host/environment?

OpenSearch 2.11.0
OpenSearch Java Client 2.8.1
Java 17

Do you have any screenshots?

image

Do you have any additional context?

./.

@fs-chris fs-chris added bug Something isn't working untriaged labels Nov 23, 2023
@dblock dblock removed the untriaged label Dec 4, 2023
@dblock
Copy link
Member

dblock commented Dec 4, 2023

This is an awkward feature. Are those typed keys added client or server side? Can you get two aggregations with the same name and different type? Either way giving the option make sense, want to try to implement it @fs-chris?

Long story is that I'd prefer a non-ambiguous response where the key is always the same, and that the body of the aggregation response contains either the separate name of the aggregation and the type, or vice-versa.

@fs-chris
Copy link
Contributor Author

I suppose (without having looked into the code) that this is added by the client. The client prefixes the aggregation's name in the request which then occurs identically in the response, since the server does not touch the aggregation's name.
So, this simply preserves the type information beyond the request/response round trip.

In the response it is then used for determining the target type before parsing the aggregation's result. I.e., the aggregation's key contains the target type that is used to decide how to parse the actual result body.

@chanon-onman
Copy link

Hi, is there a way to disable this mechanism in opensearch-java? I got similar problem that type name breaks client applications when migrating from Elasticsearch library to opensearch-java library.

@Xtansia Xtansia added enhancement New feature or request and removed bug Something isn't working labels Nov 14, 2024
@Xtansia
Copy link
Collaborator

Xtansia commented Nov 14, 2024

@chanon-onman I am currently investigating this

@Xtansia Xtansia linked a pull request Nov 15, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants