Fixed
Details
Assignee
Yoann RodièreYoann RodièreReporter
Yoann RodièreYoann RodièreComponents
Sprint
NoneFix versions
Priority
Major
Details
Details
Assignee
Yoann Rodière
Yoann RodièreReporter
Yoann Rodière
Yoann RodièreComponents
Sprint
None
Fix versions
Priority
Created August 9, 2019 at 10:26 AM
Updated December 13, 2019 at 2:57 PM
Resolved November 12, 2019 at 8:27 AM
There are way too many aggregations for us to support them all through the query DSL.
To address use cases beyond the most simple ones, we need a way for users to define aggregations using JSON, and receive a JSON-formatted string as a result.
Something like:
AggregationKey<String> myAggregationKey = AggregationKey.of( "myAggregation" ); SearchResult<Book> result = Search.session( entityManager ).search( Book.class ) .extension( ElasticsearchExtension.get() ) .predicate( f -> f.matchAll() ) .aggregation( priceFacetsKey, f -> .fromJson( "{\"histogram\":{...}}" ) ) .fetch( 100 );
As a second step, we may want to allow users to pass an object that will extract data from the response:
AggregationKey<MyBean> myAggregationKey = AggregationKey.of( "myAggregation" ); SearchResult<Book> result = Search.session( entityManager ).search( Book.class ) .extension( ElasticsearchExtension.get() ) .predicate( f -> f.matchAll() ) .aggregation( priceFacetsKey, f -> .fromJson( "{\"histogram\":{...}}", // Use a context object so that we can later consider providing helpers, or access to the whole response c -> new MyBean( doSomeParsing( c.getJson() ) ) ) ) .fetch( 100 );
We will need a similar feature for projections, but these will be a bit harder since there are many ways to project.