# Query to find multiple docs with timestamp field within specified timerange

**URL:** https://discuss.elastic.co/t/query-to-find-multiple-docs-with-timestamp-field-within-specified-timerange/274795
**Category:** Kibana
**Tags:** kql-kibana-query-language
**Created:** [June 2, 2021, 7:04pm UTC](https://discuss.elastic.co/t/query-to-find-multiple-docs-with-timestamp-field-within-specified-timerange/274795 "2021-06-02T19:04:17Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![vishalgautam](https://avatars.discourse-cdn.com/v4/letter/v/f17d59/32.png) [@vishalgautam](https://discuss.elastic.co/u/vishalgautam)
#### Post date: [June 2, 2021, 7:04pm UTC](https://discuss.elastic.co/t/query-to-find-multiple-docs-with-timestamp-field-within-specified-timerange/274795/1 "2021-06-02T19:04:17Z")

</div>

Hello,  
We have a use case where we are indexing log files and we have to find a set of lines when they appear next to each other. Example, in the log snippet below, we need a query that will find only line # 2, 3 and 4. If we simply do an OR on "first line" or "second line" or "third line" we will get line #1 and #5 also. If somehow we can use a range query where we add a criteria that in the matching doc the timestamp field should be not more than 10 sec apart from the previous doc then only line #2, 3 and 4 will come. Is something like this possible or is there another way to achieve this?

```
1 2021-02-19 13:24:15.798411(-0500)[10224:10600] DBG first line
2 2021-02-19 14:24:15.798411(-0500)[10224:10600] DBG first line
3 2021-02-19 14:24:16.120100(-0500)[10224:10600] INF second line
4 2021-02-19 14:24:26.946610(-0500)[10224:10600] ERR third line
5 2021-02-19 15:24:26.946610(-0500)[10224:10600] ERR third line

```

Thanks in advance for your help.

---

<div class="post-metadata">

### Author: ![vishalgautam](https://avatars.discourse-cdn.com/v4/letter/v/f17d59/32.png) [@vishalgautam](https://discuss.elastic.co/u/vishalgautam)
#### Post date: [June 20, 2021, 2:34pm UTC](https://discuss.elastic.co/t/query-to-find-multiple-docs-with-timestamp-field-within-specified-timerange/274795/2 "2021-06-20T14:34:40Z")

</div>

Checking it again with the community if anyone has any suggestions for this usecase?

---

<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 18, 2021, 2:35pm UTC](https://discuss.elastic.co/t/query-to-find-multiple-docs-with-timestamp-field-within-specified-timerange/274795/3 "2021-07-18T14:35:35Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
