Search code examples
jsonindexingelasticsearchangularjs-ng-repeat

ElasticSearch Get Index Names and Store Size


I am attempting to capture a list of all the indexes and their sizes in a way that I could capture the information using Angular's $http service and then iterate through the information using the ng-repeat preferably with something like:

<ul ng-repeat="elsindex in elsIndexHttpResponse"> <li>{{elsindex.name}}:{{elsindex.size}}</li> </ul>

The closest thing I have found is this: http://localhost:9200/_cat/indices?h=index,store.size

Except:

a. its responses are not in json so easily referencing it using the ng-repeat <li> elements isn't going to work; and

b. i would like, if possible, to get the size output to reflect the same unit size (like bytes).

If this involves something complicated then I'd be grateful for pointers on where I should focus.

I am using elasticsearch v1.4.4

Many thanks


Solution

  • Index size in bytes is included with an indices stats API call:

    curl http://localhost:9200/_stats/indexing,store

    For nicely formatted JSON output, append ?pretty to the end of the URL:

    curl http://localhost:9200/_stats/indexing,store?pretty

    See the Indices stats API documentation for additional details and related information.