Search code examples
javaelasticsearchspring-data-elasticsearch

Spring data elasticsearch document count info using built in reactive client


My problem:

I am trying to get indices information:

IndexName
IndexCreationDate
IndexAlias
IndexDocumentCount
IndexSize

I am able to get some of that information via GetIndexResponse mentioned below. Which holds alias, mapping and setting objects. However none of them have IndexDocumentCount and IndexSize. How to get that info using ReactiveElasticSearchClient?

I know there is a curl call which holds everything I need, but I thought there are posibilities using spring boot elastic built in java objects?

{{elastic-search-url}}/_cat/indices?v

I am using:

ELK : 7.17
Spring boot: spring-data-elasticsearch 5.1.3
ReactiveElasticsearchIndicesClient indices = reactiveElasticsearchClient.indices();

Mono<GetIndexResponse> getIndexResponseMono = indices.get(new GetIndexRequest.Builder().index("*").build());
GetIndexResponse block = getIndexResponseMono.block();

Solution

  • You need to use ReactiveElasticsearchIndicesClient.stats(IndicesStatsRequest) to get the information about index statistics.

    btw, using Spring Data Elasticsearch 5.1 against Elasticsearch is not tested.