title: Elasticsearch shows missing and deleted docs after bulk insert
body: <p>I've encounter a strange behaviour after make some _bulk insert into elastic index.</p>
  
  <p>Lets say i have a millions of docs  , but for example I need only 227,768 docs to insert. 
  so i'm inserting with a chunk of 50,000.</p>
  
  <p>To increase performance i disable first the refresh interval with:</p>
  
  <pre><code>PUT agg_vit_2016-08-07/_settings
  {
    "index" : {
          "refresh_interval" : -1
      }
  }
  </code></pre>
  
  <p>Before the insert , I check that I have no duplicates id.</p>
  
  <p>Example of inserting bulk rows:</p>
  
  <pre><code>{ "index" : { "_index" : "agg_vit_2016-08-07", "_type" : "player", "_id" : "0" } }
      {"time":"2016-08-07T03:00:00Z","domain":"www.cbs.com","mt_id":472,"cb_id":0,"c_id":0,"master_domain":"472###www.cbs.com","child_domain":"0###www.cbs.com","combo_domain":"0###www.cbs.com","playerrequest":0,"playerload":1,"adrequest":0,"adload":0,"adview":0}
      { "index" : { "_index" : "agg_vit_2016-08-07", "_type" : "player", "_id" : "1" } }
      {"time":"2016-08-07T03:00:00Z","domain":"www.thebrick.com","mt_id":478,"cb_id":0,"c_id":0,"master_domain":"478###www.thebrick.com","child_domain":"0###www.thebrick.com","combo_domain":"0###www.thebrick.com","playerrequest":0,"playerload":3,"adrequest":0,"adload":0,"adview":0}
      { "index" : { "_index" : "agg_vit_2016-08-07", "_type" : "player", "_id" : "2" } }
      {"time":"2016-08-07T04:00:00Z","domain":"kisshealthandbeauty.com","mt_id":618,"cb_id":0,"c_id":0,"master_domain":"618###kisshealthandbeauty.com","child_domain":"0###kisshealthandbeauty.com","combo_domain":"0###kisshealthandbeauty.com","playerrequest":0,"playerload":20,"adrequest":0,"adload":0,"adview":0} 
  </code></pre>
  
  <p>....</p>
  
  <p>after stop inserting enable the refresh again with : </p>
  
  <pre><code>PUT agg_vit_2016-08-07/_settings
      {
        "index" : {
              "refresh_interval" : "1ms"
          }
      }
  </code></pre>
  
  <p>but when I query the final total count is wrong:</p>
  
  <pre><code>GET agg_vit_2016-08-07/_count
  {
    "count": 199991,
    "_shards": {
      "total": 10,
      "successful": 10,
      "failed": 0
    }
  }
  </code></pre>
  
  <p>some statistics from elastic :</p>
  
  <pre><code>  "_shards": {
      "total": 10,
      "successful": 10,
      "failed": 0
    },
    "_all": {
      "primaries": {
        "docs": {
          "count": 199991,
          "deleted": 27766
        },
        "store": {
          "size_in_bytes": 49856669,
          "throttle_time_in_millis": 0
        },
        "indexing": {
          "index_total": 227757,
          "index_time_in_millis": 26347,
          "index_current": 0,
          "index_failed": 0,
          "delete_total": 0,
          "delete_time_in_millis": 0,
          "delete_current": 0,
          "noop_update_total": 0,
          "is_throttled": false,
          "throttle_time_in_millis": 0
        },....
        ....
   "merges": {
      "current": 0,
      "current_docs": 0,
      "current_size_in_bytes": 0,
      "total": 0,
      "total_time_in_millis": 0,
      "total_docs": 0,
      "total_size_in_bytes": 0,
      "total_stopped_time_in_millis": 0,
      "total_throttled_time_in_millis": 0,
      "total_auto_throttle_in_bytes": 209715200
    },
  </code></pre>
  
  <h1>My Problem</h1>
  
  <p>When i'm querying the docs count i have missing documents.(as output stat shows)</p>
  
  <p>Don't understand what could be the problem ? ,</p>
  
  <p>why I have deleted docs <code>"deleted": 27766</code>  , and besides this , additionally  9 documents are missing  <code>"count": 199991,</code> </p>
  
  <p>Thanks!!</p>
  
  <p>Vitaly</p>