Understanding difference between /_cat/indices and /_search match_all

(John Harding) #1

If I run:

GET /267/_search
    "size": 0,
    "query": {"match_all": {}}

I get:

   "hits": {
      "total": 21055,

But if I run

GET /_cat/indices/267?v

I get

health status index pri rep docs.count docs.deleted store.size pri.store.size 
yellow open   267     5   1     891816       139508     66.1mb         66.1mb 

The first one tells me that there are 21,055 documents in the index. The second one tells me there are 891,816 documents in the index.

Please can you help me understand the difference?

Ahh... I think the answer just dawned on me - I have nested objects - and I bet the _cat version is counting those hidden documents. Is there a way to make _cat only count the visible documents? Also, is the number of non-deleted documents = docs.count - docs.deleted?

Many Thanks.

(Colin Goodheart-Smithe) #2

Yep you are exactly right. The docs.count will include your child-nested documents. I don't think there is a way to change the _cat API to report just the number of parent-nested documents because is a lower level count which is asking the underlying Lucene IndexReader for its maxDoc. Also you are right in thinking that number of non-deleted docs = docs.count - docs.deleted

(system) #3