Elasticsearch how to query on ID field higher than x
<p>I am trying to apply pagination to results by querying multiple times to get past the 10k barrier of Elasticsearch. Since the results of Elasticsearch can differ during multiple queries I want to use the generated ID to get the next results. </p>

<p>So for example, I run a query that returns 1000 results. Then I want to get the ID value of the 1000th result, and perform a query like : match : ID {{1000thID}}</p>

<p>This way I want to get the 1001 until 2000 result. after that 2001 until 3000, so on.</p>

<p>I currently use the Elasticsearch DSL for python to query on domain name like:</p>

<pre><code>search.query('match', domainname=domainname)
</code></pre>

<p>How do I rebuild this code to match above requirements. ('match',_ID > ID_Variable) </p>

<p>The best way to achieve what you want is to use the scroll/can API. However, if you still want to proceed that way, you can do it like this:</p>

<pre><code>last_id = ...
search.filter('range', id={'gt': last_id + 1, 'lt': last_id + 1000})
</code></pre>

python elasticsearch range elasticsearch-dsl elasticsearch-py