# Getting every 2nd element from \_source

**URL:** https://discuss.elastic.co/t/getting-every-2nd-element-from-source/295123
**Category:** Elasticsearch
**Created:** [January 23, 2022, 1:59am UTC](https://discuss.elastic.co/t/getting-every-2nd-element-from-source/295123 "2022-01-23T01:59:25Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![Tomo\_M](https://avatars.discourse-cdn.com/v4/letter/t/848f3c/32.png) [@Tomo\_M](https://discuss.elastic.co/u/Tomo_M)
#### Post date: [January 23, 2022, 3:27pm UTC](https://discuss.elastic.co/t/getting-every-2nd-element-from-source/295123/4 "2022-01-23T15:27:23Z")

</div>

So the true problem is the necessary `size` for query could be hundreds of thousands and too wasteful.

Then you can use [Date histogram aggregation | Elasticsearch Guide [7.16] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-datehistogram-aggregation.html) with [Top hits aggregation | Elasticsearch Guide [7.16] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-top-hits-aggregation.html).  
Top hit with size=1 and sort by date, you can get last (or first) documents in the date-histo buckets.

---

_[View the full topic](https://discuss.elastic.co/t/getting-every-2nd-element-from-source/295123)._
