# Query design question

**URL:** <https://discuss.elastic.co/t/query-design-question/11768>\
**Category:** Elasticsearch\
**Created:** [May 1, 2013, 4:45pm UTC](https://discuss.elastic.co/t/query-design-question/11768 "2013-05-01T16:45:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mohit\_Anchlia](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@Mohit\_Anchlia](https://discuss.elastic.co/u/Mohit_Anchlia)\
**Post date:** [May 1, 2013, 4:45pm UTC](https://discuss.elastic.co/t/query-design-question/11768/1 "2013-05-01T16:45:34Z")

</div>

I am wondering what's the right way of querying the following scenarios:

1. Userid with docs representing unique type of events A,B ..etc Each event  
is a separate document.  
query: How to query all documents that have events A but not event B join  
by userid? If possible group them by userid

2. Userid with docs representing events A,B and each event has a timestamp  
with it. Each event is a separate document  
query: How to query that gives unique sequence of events? For eg: A-\>B-\>C  
or A-\>C-\>B accross all users for a given timeperiod.

This is easy to do in RDBMS, I am wondering if we can do this in  
elasticsearch as well.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:38am UTC](https://discuss.elastic.co/t/query-design-question/11768/2 "2017-07-06T02:38:47Z")

</div>


