|
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;
|
@@ -328,6 +329,17 @@ public Mono<DeleteResponse> delete(HttpHeaders headers, DeleteRequest deleteRequ
|
328 | 329 | .publishNext();
|
329 | 330 | }
|
330 | 331 |
|
| 332 | + /* |
| 333 | + * (non-Javadoc) |
| 334 | + * @see org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient#count(org.springframework.http.HttpHeaders, org.elasticsearch.action.search.SearchRequest) |
| 335 | + */ |
| 336 | + @Override |
| 337 | + public Mono<Long> count(HttpHeaders headers, CountRequest countRequest) { |
| 338 | + return sendRequest(countRequest, RequestCreator.count(), CountResponse.class, headers) // |
| 339 | + .map(CountResponse::getCount) // |
| 340 | + .next(); |
| 341 | + } |
| 342 | + |
331 | 343 | /*
|
332 | 344 | * (non-Javadoc)
|
333 | 345 | * @see org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient#ping(org.springframework.http.HttpHeaders, org.elasticsearch.action.search.SearchRequest)
|
@@ -572,13 +584,12 @@ private static GetResult getResponseToGetResult(GetResponse response) {
|
572 | 584 |
|
573 | 585 | // -->
|
574 | 586 |
|
575 |
| - private <Req extends ActionRequest, Resp extends ActionResponse> Flux<Resp> sendRequest(Req request, |
576 |
| - Function<Req, Request> converter, Class<Resp> responseType, HttpHeaders headers) { |
| 587 | + private <Req extends ActionRequest, Resp> Flux<Resp> sendRequest(Req request, Function<Req, Request> converter, |
| 588 | + Class<Resp> responseType, HttpHeaders headers) { |
577 | 589 | return sendRequest(converter.apply(request), responseType, headers);
|
578 | 590 | }
|
579 | 591 |
|
580 |
| - private <AR extends ActionResponse> Flux<AR> sendRequest(Request request, Class<AR> responseType, |
581 |
| - HttpHeaders headers) { |
| 592 | + private <Resp> Flux<Resp> sendRequest(Request request, Class<Resp> responseType, HttpHeaders headers) { |
582 | 593 |
|
583 | 594 | String logId = ClientLogger.newLogId();
|
584 | 595 |
|
@@ -807,6 +818,10 @@ static Function<FlushRequest, Request> flushIndex() {
|
807 | 818 | return RequestConverters::flushIndex;
|
808 | 819 | }
|
809 | 820 |
|
| 821 | + static Function<CountRequest, Request> count() { |
| 822 | + return RequestConverters::count; |
| 823 | + } |
| 824 | + |
810 | 825 | }
|
811 | 826 |
|
812 | 827 | /**
|
|
0 commit comments