Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Elastic search document count

I am having a Elastic search running 2.2 version. I have created index and loaded sample documents. I found some problem in it. When i give

GET index/type/_count

I am getting the correct answer

{
   "count": 9998,
   "_shards": {
      "total": 5,
      "successful": 5,
      "failed": 0
   }
}

But when i see the things using http://IP:9200/_cat/indices?v

health status index pri rep docs.count docs.deleted store.size pri.store.size     
yellow open   index  5   1      79978            0     32.1mb         32.1mb 

Where docs.count : 79978. Which is wrong.

Why i am seeing docs.count with wrong value. The exact document count is 9998

like image 739
backtrack Avatar asked Apr 26 '16 06:04

backtrack


People also ask

How many documents can Elasticsearch handle?

Each Elasticsearch shard is a Lucene index. The maximum number of documents you can have in a Lucene index is 2,147,483,519. The Lucene index is divided into smaller files called segments.

Is Elasticsearch document based?

Elasticsearch is a document oriented database. The entire object graph you want to search needs to be indexed, so before indexing your documents, they must be denormalized.

Is Elasticsearch Difficult?

Elasticsearch is a little industrial and by a little industrial I mean a lot industrial. Interacting with the service is pretty difficult, searching through data is hard and the documentation is cryptic at best; get something wrong and you can expect to sit for 3 hours while your data re-indexes.


1 Answers

GET index/type/_count will return the top-level document count.

docs.count in _cat/indices returns the count of all documents, including artificial documents that have been created for nested fields.

That's why you see a difference:

  • The former count (i.e. 9998) will tell you how many Elasticsearch documents are in your index, i.e. how many you have indexed.
  • The latter count (i.e. 79978) will tell you how many Lucene documents are in your index.

So if one ES document contain a nested field with 5 sub-elements, you'll see 1 ES document, but 6 Lucene documents. Judging by the counts, each of your ES document has between 7 and 8 nested elements within it.

like image 79
Val Avatar answered Oct 29 '22 05:10

Val