# Find user on multiple condition after aggregation result

**URL:** <https://discuss.elastic.co/t/find-user-on-multiple-condition-after-aggregation-result/201171>\
**Category:** Elasticsearch\
**Created:** [September 26, 2019, 7:41am UTC](https://discuss.elastic.co/t/find-user-on-multiple-condition-after-aggregation-result/201171 "2019-09-26T07:41:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vaibhav\_morye](https://avatars.discourse-cdn.com/v4/letter/v/ecc23a/32.png) [@vaibhav\_morye](https://discuss.elastic.co/u/vaibhav_morye)\
**Post date:** [September 26, 2019, 7:41am UTC](https://discuss.elastic.co/t/find-user-on-multiple-condition-after-aggregation-result/201171/1 "2019-09-26T07:41:23Z")

</div>

I want to **find user who have user\_action searched-for-cake and got-cake**.

sample index is as follow.

{  
{  
user\_id:"ad97b3fe-0d55-4133-9367-1",  
user\_action:"searched-for-cake"   
},

```
{
	user_id:"ad97b3fe-0d55-4133-9367-1",
	action:"got-cake"		
},

{
	user_id:"ad97b3fe-0d55-4133-9367-3",
	action:"need-help"		
},

{
	user_id:"ad97b3fe-0d55-4133-9367-4",
	user_action:"searched-for-cake"		
},

{
	user_id:"ad97b3fe-0d55-4133-9367-4",
	action:"got-cake"		
},

{
	user_id:"ad97b3fe-0d55-4133-9367-3",
	action:"got-cake"		
}

```

}

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [September 26, 2019, 2:00pm UTC](https://discuss.elastic.co/t/find-user-on-multiple-condition-after-aggregation-result/201171/2 "2019-09-26T14:00:39Z")

</div>

Take a look at the [nested datatype](https://www.elastic.co/guide/en/elasticsearch/reference/7.3/nested.html), the [nested query](https://www.elastic.co/guide/en/elasticsearch/reference/7.3/query-dsl-nested-query.html) and also the [nested aggregation](https://www.elastic.co/guide/en/elasticsearch/reference/7.3/search-aggregations-bucket-nested-aggregation.html)

hope this helps!

---

<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:** [October 24, 2019, 2:00pm UTC](https://discuss.elastic.co/t/find-user-on-multiple-condition-after-aggregation-result/201171/3 "2019-10-24T14:00:42Z")

</div>

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