Skip to content

Creating aggregation from json via supplied reader #795

Closed
@SwonVIP

Description

@SwonVIP

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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions