|
47 | 47 | import org.apache.http.util.EntityUtils;
|
48 | 48 | import org.elasticsearch.ElasticsearchStatusException;
|
49 | 49 | import org.elasticsearch.action.ActionRequest;
|
50 |
| -import org.elasticsearch.action.ActionResponse; |
51 | 50 | import org.elasticsearch.action.admin.indices.close.CloseIndexRequest;
|
52 | 51 | import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
|
53 | 52 | import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
|
|
77 | 76 | import org.elasticsearch.action.update.UpdateRequest;
|
78 | 77 | import org.elasticsearch.action.update.UpdateResponse;
|
79 | 78 | import org.elasticsearch.client.Request;
|
| 79 | +import org.elasticsearch.client.core.CountRequest; |
| 80 | +import org.elasticsearch.client.core.CountResponse; |
80 | 81 | import org.elasticsearch.common.unit.TimeValue;
|
81 | 82 | import org.elasticsearch.common.xcontent.DeprecationHandler;
|
82 | 83 | import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
@@ -325,6 +326,17 @@ public Mono<DeleteResponse> delete(HttpHeaders headers, DeleteRequest deleteRequ
|
325 | 326 | .publishNext();
|
326 | 327 | }
|
327 | 328 |
|
| 329 | + /* |
| 330 | + * (non-Javadoc) |
| 331 | + * @see org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient#count(org.springframework.http.HttpHeaders, org.elasticsearch.action.search.SearchRequest) |
| 332 | + */ |
| 333 | + @Override |
| 334 | + public Mono<Long> count(HttpHeaders headers, CountRequest countRequest) { |
| 335 | + return sendRequest(countRequest, RequestCreator.count(), CountResponse.class, headers) // |
| 336 | + .map(CountResponse::getCount) // |
| 337 | + .next(); |
| 338 | + } |
| 339 | + |
328 | 340 | /*
|
329 | 341 | * (non-Javadoc)
|
330 | 342 | * @see org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient#ping(org.springframework.http.HttpHeaders, org.elasticsearch.action.search.SearchRequest)
|
@@ -559,13 +571,12 @@ private static GetResult getResponseToGetResult(GetResponse response) {
|
559 | 571 |
|
560 | 572 | // -->
|
561 | 573 |
|
562 |
| - private <Req extends ActionRequest, Resp extends ActionResponse> Flux<Resp> sendRequest(Req request, |
563 |
| - Function<Req, Request> converter, Class<Resp> responseType, HttpHeaders headers) { |
| 574 | + private <Req extends ActionRequest, Resp> Flux<Resp> sendRequest(Req request, Function<Req, Request> converter, |
| 575 | + Class<Resp> responseType, HttpHeaders headers) { |
564 | 576 | return sendRequest(converter.apply(request), responseType, headers);
|
565 | 577 | }
|
566 | 578 |
|
567 |
| - private <AR extends ActionResponse> Flux<AR> sendRequest(Request request, Class<AR> responseType, |
568 |
| - HttpHeaders headers) { |
| 579 | + private <Resp> Flux<Resp> sendRequest(Request request, Class<Resp> responseType, HttpHeaders headers) { |
569 | 580 |
|
570 | 581 | String logId = ClientLogger.newLogId();
|
571 | 582 |
|
@@ -782,6 +793,10 @@ static Function<FlushRequest, Request> flushIndex() {
|
782 | 793 | return RequestConverters::flushIndex;
|
783 | 794 | }
|
784 | 795 |
|
| 796 | + static Function<CountRequest, Request> count() { |
| 797 | + return RequestConverters::count; |
| 798 | + } |
| 799 | + |
785 | 800 | }
|
786 | 801 |
|
787 | 802 | /**
|
|
0 commit comments