title: Elasticsearch scroll scan query doesn't return all documents, missing first set
body: <p>I'm trying to scroll my ES index and grab all the documents but it looks like I keep missing the first set of documents returned by the initial scroll. For example if my scroll size is 10 and my query returns a total of 100 after scrolling I would only have 90 documents. Any suggestions on what I'm missing?</p>
  
  <p>Here's what I've currently tried:</p>
  
  <pre><code>$json = '{"query":{"bool":{"must":[{"match_all":{}}]}}}';
  
  $params = [
      "scroll" =&gt; "1m",
      "size" =&gt; 50,
      "index" =&gt; "myindex",
      "type" =&gt; "mytype",
      "body" =&gt; $json 
  ];
  
  $results = $client-&gt;search($params);
  $scroll_size = $results['hits']['total']; // returns total docs that match query
  $s_id = $results['_scroll_id'];
  
  print " total results:   " . $scroll_size;
  
  //scroll
  $count = 0;
  while ($scroll_size &gt; 0) {
      print "  SCROLLING...";
      $scroll_results = $client-&gt;scroll([
          'scroll_id' =&gt; $s_id,
          'scroll' =&gt; '1m'
      ]);
  
      // get number of results returned in the last scroll
      $scroll_size = sizeof($scroll_results['hits']['hits']);
      print "  scroll size: " . $scroll_size;
  
      // do something with results
      for ($i=0; $i&lt;$scroll_size; $i++) {
          $count++;
      }
  }
  print " total id count: " . $id_count;
  </code></pre>