Query for counting docs per type?

(mos) #1

We are using the following request, to return the number of documents per doc-type. But it just lists all types with more then zero documents. How can we also return all types that have no document yet?

GET /myIndex/_search?search_type=count
    "aggs": {
        "count_by_type": {
            "terms": {
                "field": "_type"

(Mark Walkom) #2

You can't do this because there can never be a doc without a _type.

(mos) #3

Ok, so I need to read all types separately, to catch those with zero hits? Is there a simple query to read just all available types per index. (_mapping is to much information)

(system) #4