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

Creating aggregation from json via supplied reader #795

Closed
SwonVIP opened this issue May 2, 2024 · 1 comment · Fixed by #815
Closed

Creating aggregation from json via supplied reader #795

SwonVIP opened this issue May 2, 2024 · 1 comment · Fixed by #815
Labels
Area: Helpers Category: Bug Something isn't working

Comments

@SwonVIP
Copy link

SwonVIP commented May 2, 2024

Java API client version

8.13.2

Java version

OpenJDK Runtime Environment Temurin-21.0.2+13

Elasticsearch Version

8.6.2

Problem description

Hello,

it seems like the fromJson method on the Aggregation and Query objects work differently and the Builders returned work a bit different.

In our test setup we are using a function like this to create a query fixture from a supplied json which works fine:

	public static Query createQueryFromFile(String fileContent) {
		return Query.of(q1 -> q1.withJson(new StringReader(fileContent)));
	}

However doing the same for aggregations results in a type error:

	public static Aggregation createAggregationFromFile(String fileContent) {
		return Aggregation.of(agg1 -> agg1.withJson(new StringReader(fileContent)));
	}	

Bad return type in lambda expression: Builder cannot be converted to ObjectBuilder

So it seems the interface is different although to me as a consumer they should work in a similar way?

@l-trotta
Copy link
Contributor

l-trotta commented May 3, 2024

Hello, thank you for reporting this! Yes in theory it should work the same, we'll investigate on this.

@l-trotta l-trotta added Category: Bug Something isn't working Area: Helpers labels May 3, 2024
This was referenced May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Helpers Category: Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants