# Get all document between two of them

**URL:** https://discuss.elastic.co/t/get-all-document-between-two-of-them/25264
**Category:** Elasticsearch
**Created:** [July 9, 2015, 9:00pm UTC](https://discuss.elastic.co/t/get-all-document-between-two-of-them/25264 "2015-07-09T21:00:12Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Smasell](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/smasell/32/43483_2.png) [@Smasell](https://discuss.elastic.co/u/Smasell)
#### Post date: [July 9, 2015, 9:00pm UTC](https://discuss.elastic.co/t/get-all-document-between-two-of-them/25264/1 "2015-07-09T21:00:12Z")

</div>

Hi!  
I have a lot of documents, some of them with message: "Logged in" and "Logged out"(not all).  
How can i get all documents between last coming documents with message "Logged in" and "Logged out"  
For example:

1 Document  
2 Message "Logged in"  
3 Document  
4 Document  
5 Message "Loged out"  
6 Document  
7 Document  
I need response that returns me:  
2 Message "Logged in"  
3 Document  
4 Document  
5 Message "Logged out"

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [July 10, 2015, 2:03am UTC](https://discuss.elastic.co/t/get-all-document-between-two-of-them/25264/2 "2015-07-10T02:03:28Z")

</div>

You will need to manage this yourself, there's nothing in ES that can do this.

---

<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, 12:02am UTC](https://discuss.elastic.co/t/get-all-document-between-two-of-them/25264/3 "2017-07-06T00:02:27Z")

</div>


