|
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;
|
|
79 | 78 | import org.elasticsearch.action.update.UpdateRequest;
|
80 | 79 | import org.elasticsearch.action.update.UpdateResponse;
|
81 | 80 | import org.elasticsearch.client.Request;
|
| 81 | +import org.elasticsearch.client.core.CountRequest; |
| 82 | +import org.elasticsearch.client.core.CountResponse; |
82 | 83 | import org.elasticsearch.common.unit.TimeValue;
|
83 | 84 | import org.elasticsearch.common.xcontent.DeprecationHandler;
|
84 | 85 | import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
@@ -322,6 +323,17 @@ public Mono<DeleteResponse> delete(HttpHeaders headers, DeleteRequest deleteRequ
|
322 | 323 | .publishNext();
|
323 | 324 | }
|
324 | 325 |
|
| 326 | + /* |
| 327 | + * (non-Javadoc) |
| 328 | + * @see org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient#count(org.springframework.http.HttpHeaders, org.elasticsearch.action.search.SearchRequest) |
| 329 | + */ |
| 330 | + @Override |
| 331 | + public Mono<Long> count(HttpHeaders headers, CountRequest countRequest) { |
| 332 | + return sendRequest(countRequest, RequestCreator.count(), CountResponse.class, headers) // |
| 333 | + .map(CountResponse::getCount) // |
| 334 | + .next(); |
| 335 | + } |
| 336 | + |
325 | 337 | /*
|
326 | 338 | * (non-Javadoc)
|
327 | 339 | * @see org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient#ping(org.springframework.http.HttpHeaders, org.elasticsearch.action.search.SearchRequest)
|
@@ -566,13 +578,12 @@ private static GetResult getResponseToGetResult(GetResponse response) {
|
566 | 578 |
|
567 | 579 | // -->
|
568 | 580 |
|
569 |
| - private <Req extends ActionRequest, Resp extends ActionResponse> Flux<Resp> sendRequest(Req request, |
570 |
| - Function<Req, Request> converter, Class<Resp> responseType, HttpHeaders headers) { |
| 581 | + private <Req extends ActionRequest, Resp> Flux<Resp> sendRequest(Req request, Function<Req, Request> converter, |
| 582 | + Class<Resp> responseType, HttpHeaders headers) { |
571 | 583 | return sendRequest(converter.apply(request), responseType, headers);
|
572 | 584 | }
|
573 | 585 |
|
574 |
| - private <AR extends ActionResponse> Flux<AR> sendRequest(Request request, Class<AR> responseType, |
575 |
| - HttpHeaders headers) { |
| 586 | + private <Resp> Flux<Resp> sendRequest(Request request, Class<Resp> responseType, HttpHeaders headers) { |
576 | 587 |
|
577 | 588 | String logId = ClientLogger.newLogId();
|
578 | 589 |
|
@@ -801,6 +812,10 @@ static Function<FlushRequest, Request> flushIndex() {
|
801 | 812 | return RequestConverters::flushIndex;
|
802 | 813 | }
|
803 | 814 |
|
| 815 | + static Function<CountRequest, Request> count() { |
| 816 | + return RequestConverters::count; |
| 817 | + } |
| 818 | + |
804 | 819 | }
|
805 | 820 |
|
806 | 821 | /**
|
|
0 commit comments