title: How to handle pagination when the source data changes frequently
body: <p>Specifically, I'm using Elasticsearch to do pagination, but this question could apply to any database.</p>
  
  <p>Elasticsearch provides methods to <a href="http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/pagination.html" rel="noreferrer">paginate search results</a> with handy <code>from</code> and <code>to</code> parameters.</p>
  
  <p>So I run a query <code>get me the most recent data from result 1 to 10</code></p>
  
  <p>This works great.</p>
  
  <p>The user clicks "next page" and the query is:
  <code>get me the most recent data from result 11 to 20</code></p>
  
  <p>The problem is that in the time between the two queries, 2 new records have been added to the backing database, which means the paginated results will overlap (the last 2 from the first page show up as first two on the second page).</p>
  
  <p>What's the best solution to avoid this? Right now, I'm adding a filter to the query that tell it to only include results later than the last result of the previous query. But it just seems hackish.</p>