Skip to content

Commit b7d60ce

Browse files
committed
Add count methods to ELC's ReactiveElasticsearchClient.
Implemented count methods using CountRequest directly with ELC's ReactiveElasticsearchClient, eliminating the need to initialize any entity or repository. Closes #2749
1 parent 98716a8 commit b7d60ce

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/main/java/org/springframework/data/elasticsearch/client/elc/ReactiveElasticsearchClient.java

+21
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
* Reactive version of {@link co.elastic.clients.elasticsearch.ElasticsearchClient}.
3737
*
3838
* @author Peter-Josef Meisch
39+
* @author maryantocinn
3940
* @since 4.4
4041
*/
4142
public class ReactiveElasticsearchClient extends ApiClient<ElasticsearchTransport, ReactiveElasticsearchClient>
@@ -227,6 +228,26 @@ public Mono<DeleteByQueryResponse> deleteByQuery(
227228
return deleteByQuery(fn.apply(new DeleteByQueryRequest.Builder()).build());
228229
}
229230

231+
/**
232+
* @since 5.4
233+
*/
234+
public Mono<CountResponse> count(CountRequest request) {
235+
236+
Assert.notNull(request, "request must not be null");
237+
238+
return Mono.fromFuture(transport.performRequestAsync(request, CountRequest._ENDPOINT, transportOptions));
239+
}
240+
241+
/**
242+
* @since 5.4
243+
*/
244+
public Mono<CountResponse> count(Function<CountRequest.Builder, ObjectBuilder<CountRequest>> fn) {
245+
246+
Assert.notNull(fn, "fn must not be null");
247+
248+
return count(fn.apply(new CountRequest.Builder()).build());
249+
}
250+
230251
// endregion
231252
// region search
232253

0 commit comments

Comments
 (0)