Reputation: 709
Here is what I got from the two URLs
http://localhost:9200/_cat/indices?v
health status index pri rep docs.count docs.deleted store.size pri.store.size
green open myindex 5 1 40 0 263.4kb 131.7kb
http://localhost:9200/myindex/_search
hits: {total: 10, max_score: 1, hits: [...]}
hits.total=10 returned from the second URL is expected, but why docs.count = 40 returned the first URL is different? Thanks!
Upvotes: 3
Views: 910
Reputation: 749
If you stored documents with type nested in the index, the difference in document is most likely because of that.
Each nested document is stored as separate hidden document within Elasticsearch to be able to keep relationships within these nested documents. For more information, it is well documented here
Thus, as it is hidden, you can not find it via the search api and only get the "main" documents as results.
Moreover, there is an issue on github which should clarify the difference between the two counts.
Upvotes: 2
Reputation: 53525
One option is that you have deleted docs: documents are immutable in ES so any modification (including delete) will create a new copy of the doc with a new version-number.
The call to _cat/indices?v
returns a count of all the docs including the deleted ones, though you can't access them through _search
Upvotes: 0