# Search based on Document Sequencing

**URL:** <https://discuss.elastic.co/t/search-based-on-document-sequencing/42021>\
**Category:** Elasticsearch\
**Created:** [February 17, 2016, 11:47am UTC](https://discuss.elastic.co/t/search-based-on-document-sequencing/42021 "2016-02-17T11:47:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rohan\_Jain](https://avatars.discourse-cdn.com/v4/letter/r/e36b37/32.png) [@Rohan\_Jain](https://discuss.elastic.co/u/Rohan_Jain)\
**Post date:** [February 17, 2016, 11:47am UTC](https://discuss.elastic.co/t/search-based-on-document-sequencing/42021/1 "2016-02-17T11:47:55Z")

</div>

hey i have log files of email. A user logs in and his session created is true.HIs session end when he logs out and log file shows seesion end. Now i need to count the number of sessions of a user and for each particular session no of emails sent.

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [February 17, 2016, 2:56pm UTC](https://discuss.elastic.co/t/search-based-on-document-sequencing/42021/2 "2016-02-17T14:56:00Z")

</div>

I don't think this is something that Elasticsearch can answer very easily now. I'd love to be able to answer these questions efficiently though.

You could get something half way, like count the distinct number of sessions for a user and then count the number of emails they sent to get the number of emails per session. But it wouldn't exactly what you asked for.

@polyfractal and @jimferenczi might know more. Like, if we implemented some kind of `session, time` ordered walk of documents then it'd be possible to implement an efficiently aggregation that counts the sessions that have contain an email, right? I guess we could do something fancy with a bit set and global ordinals to count the answers too....

---

<div class="post-metadata">

**Author:** ![Rohan\_Jain](https://avatars.discourse-cdn.com/v4/letter/r/e36b37/32.png) [@Rohan\_Jain](https://discuss.elastic.co/u/Rohan_Jain)\
**Post date:** [February 23, 2016, 11:31am UTC](https://discuss.elastic.co/t/search-based-on-document-sequencing/42021/3 "2016-02-23T11:31:06Z")

</div>

thanx for the answer 🙂

---

<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 5, 2017, 11:14pm UTC](https://discuss.elastic.co/t/search-based-on-document-sequencing/42021/4 "2017-07-05T23:14:15Z")

</div>


