# Query parents, based on children ratio / percentage

**URL:** <https://discuss.elastic.co/t/query-parents-based-on-children-ratio-percentage/169057>\
**Category:** Elasticsearch\
**Created:** [February 19, 2019, 3:55pm UTC](https://discuss.elastic.co/t/query-parents-based-on-children-ratio-percentage/169057 "2019-02-19T15:55:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![LindaBrett](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lindabrett/32/41107_2.png) [@LindaBrett](https://discuss.elastic.co/u/LindaBrett)\
**Post date:** [February 19, 2019, 3:55pm UTC](https://discuss.elastic.co/t/query-parents-based-on-children-ratio-percentage/169057/1 "2019-02-19T15:55:50Z")

</div>

Hi,

I have an index with a parent-child relationship.  
What i basically wan't to do is to query with an percentage, let's say we have users and a list of transactions.

Parents:  
{  
"id": 1,  
"name": "Eric"  
},  
{  
"id": 2,  
"name": "James"  
}

Children:  
{  
 "parent": 1,  
 "shopping\_place": "Norway",  
 "trans\_id": 11  
},  
{  
 "parent": 1,  
 "shopping\_place": "Cuba",  
 "trans\_id": 22  
},  
{  
 "parent": 1,  
 "shopping\_place": "Cuba",  
 "trans\_id": 33  
},  
{  
 "parent": 1,  
 "shopping\_place": "Cuba",  
 "trans\_id": 44  
},  
{  
 "parent": 2,  
 "shopping\_place": "Norway",  
 "trans\_id": 55  
},  
{  
"parent": 2,  
"shopping\_place": "Cuba",  
"trans\_id": 55  
}

Let's say i want to find all parents which has at least 25% of total child-transactions done in norway, how would a query like that look like?

---

<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:** [March 19, 2019, 3:55pm UTC](https://discuss.elastic.co/t/query-parents-based-on-children-ratio-percentage/169057/2 "2019-03-19T15:55:50Z")

</div>

Closed on March 19, 2019, 3:55pm UTC

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