Get the first document from every Elasticsearch route
<p>I have an Elasticsearch index with route key of day in the following format <code>"yyyyMMdd"</code>. Each day a lot of new documents are added. At the end of the month I would like to query if there are any days when for some reason a document haven't been added by a source. There is a <code>source_id</code> field representing the source.</p>

<p>I got it so far that I need to give all the routekeys, like <code>20160101</code>,<code>20160102</code> etc. and filter by the <code>source_id</code>. But this can return hundreds of thounsands of documents, I may need to paginate through them all.</p>

<p>Is there a way to only know if there is a routing key which doesn't have matching document with the given <code>source_id</code>, so essentially I would only return 31 documents or less to my application code, so it would be easy to iterate through and check if there is a day without document.</p>

<p>Any ideas?</p>