# Time-based searches near a certain timestamp

**URL:** <https://discuss.elastic.co/t/time-based-searches-near-a-certain-timestamp/5011>\
**Category:** Elasticsearch\
**Created:** [August 1, 2011, 12:25am UTC](https://discuss.elastic.co/t/time-based-searches-near-a-certain-timestamp/5011 "2011-08-01T00:25:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jat850](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jat850](https://discuss.elastic.co/u/jat850)\
**Post date:** [August 1, 2011, 12:25am UTC](https://discuss.elastic.co/t/time-based-searches-near-a-certain-timestamp/5011/1 "2011-08-01T00:25:42Z")

</div>

i am trying to perform a search where I have an array of terms (serial numbers) and I would like to get at least one (but preferably only the first) document containing that serial number after a given timeframe.

So as an example, I have 5 serial numbers and I'd like to get the first entry for each serial number on that date. I'd like to get only one for each serial number (JUST the first).

I could take the trivial approach and get all documents within a known large time range and then pare it down but it may be a lot (also, it may vary greatly) and I would like to strongly limit my result set.

Is something like this possible? I apologize in advance because I am very new to ElasticSearch and still learning my way around queries.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 3:58am UTC](https://discuss.elastic.co/t/time-based-searches-near-a-certain-timestamp/5011/2 "2017-07-06T03:58:44Z")

</div>


