Reactive Elasticsearch and Paging

Viewed 699

I am using a Reactive client for Elasticsearch. Both of them (ReactiveElasticsearchTemplate or ReactiveCrudRepository) have support for Flux/Mono and this is working fine for me.

My current problem is that using ReactiveElasticsearchTemplate:

return reactiveElasticsearchTemplate.search(
    new NativeSearchQueryBuilder()
        .withPageable(PageRequest.of(0, 10))
        .build(),
    UserDocument.class
)

It is returning slice, but I don't have any information about total elements, as method signature returns Flux<SearchHit<UserDocument>>. Ideally, I would like to get SearchHits or something similar, but I don't know how to achieve it.

1 Answers

Currently this information is not available in the reactive implementation there is an open issue for that. The only possibility at the moment is sending a count request first.

Related