title: how to do pagination with elasticsearch? from vs scroll API
body: <p>I'm using elasticsearch as DB to store a large batch of log data.
  I know there are 2 ways to do pagination:</p>
  
  <ol>
  <li><p>Use size and from API</p></li>
  <li><p>Use scroll API</p></li>
  </ol>
  
  <p>Now I'm using 'from' to do pagination.Get page and size parameters from front end,and at back end(Java)</p>
  
  <pre><code>searchSourceBuilder.size(size);
  searchSourceBuilder.from(page * size);
  </code></pre>
  
  <p>However, if <code>page*size</code> > 10000, an exception thrown from ES.</p>
  
  <p>Can I use scroll API to do pagination?</p>
  
  <p>I know that if I use scroll API, the <code>searchResponse</code> object will return me a <code>_scroll_id</code>, which looks like a <code>base64</code> string.</p>
  
  <p>How can I control page and size?</p>
  
  <p>It seems <code>Scroll API</code> only support successive page number?</p>