0

I need to fetch the count of indices available in ElasticSearch. Right now i am using /_cat/indices to fetch the list of indices and mapping it with array list and fetching the count. Is there any other API through which I can fetch the count of indices rather than fetching the list and counting it?

Thanks.

1
  • Wondering the same thing. Any update? Commented Oct 30, 2021 at 2:45

3 Answers 3

3
$ curl <elasticsearch-host-port>/_cluster/stats

And then look for indices.count in the response.

Sign up to request clarification or add additional context in comments.

Comments

1

Since you're using the _cat/indices API, you could simply return the results in JSON (instead of tabular form) and then pipe that into jq in order to get the length of the index array you get in the response.

curl -s localhost:9200/_cat/indices?format=json | jq '. | length'

This will return a number equals to the number of indices you have.

Comments

0

GET Call In POSTMAN -> http://address:9200/_cluster/stats OR

curl --location --request GET 'http://address:9200/_cluster/stats'

===============================

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.