title: Elasticsearch document count returned by _stats versus _count
body: <p>I'm trying to get statistics/counts on indices in my elasticsearch cluster (1.2.1). I was using the <a href="http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-stats.html" rel="noreferrer">Indices Stats API</a> (_stats endpoint) to get the total number of primary documents and their size on disk. However, I started experimenting with the <a href="http://www.elastic.co/guide/en/elasticsearch/reference/current/search-count.html" rel="noreferrer">Count API</a> (_count endpoint) and noticed that the values do not align. </p>
  
  <p>What is the difference between these values? It's not entirely clear from the documentation though a clue in the documentation indicates that the value returned from Indicies Stats can change when refreshing the index. This makes me wonder if this is a lower-level value from the Lucene layer.</p>
  
  <p>Indices Stats API</p>
  
  <pre><code>localhost:9200/my_index/_stats
  
  ...snip...
  
  "_all" : {
    "primaries" : {
      "docs" : {
        "count" : 8284,
        "deleted" : 87
      },
    }
  }
  
  ...snip...
  </code></pre>
  
  <p>Count API </p>
  
  <pre><code>localhost:9200/my_index/_count
  
  {
    "count" : 6854,
    "_shards" : {
      "total" : 40,
      "successful" : 40,
      "failed" : 0
    }
  }
  </code></pre>