Search code examples
elasticsearchelasticsearch-indices

Can I narrow results from Elastic Search _stats get?


I am using elastic search for the project I'm working on and I was wondering if there was a way to narrow the results I get from an indices stats search. https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-stats.html

I currently use the docs to narrow the data I get back about the indices but now I want to only get back ones with a doc count greater than 0. Does anyone know if this is possible or how to?

Thanks!

For elastic search 1.5.2


Solution

  • If you're concerned about the size of the response (i.e. if you many many indices with many shards), the best you can do is to use response filtering (available only since ES 1.7) and only retrieve the docs field that you can further filter on the client-side:

    curl 'localhost:9200/_stats/docs?pretty&filter_path=**.docs.count'