Retrieve aggregations using Spring Data Elasticsearch Reactive Template

Viewed 705

We are using Spring Data Elasticsearch Reactive Template

Query searchQuery = new NativeSearchQueryBuilder()
                .withQuery(queryBuilder)
                .withPageable(PageRequest.of(0, 10))
                .addAggregation(AggregationBuilders.terms("categories").field("category"))
                .build();

reactiveElasticsearchTemplate.search(searchQuery, documentType, IndexCoordinates.of(indexName))

In response we have Flux<SearchHit<T>> but there are no methods to retrieve aggregations.

How to retrieve the aggregations?

1 Answers

The ReactiveElasticsearchTemplate has aggregate methods.

See the corresponding API interface

There is no combination of the single entities in a flux and the aggregations in the reactive part.

Related