# Parents with distinct children

**URL:** <https://discuss.elastic.co/t/parents-with-distinct-children/178112>\
**Category:** Elasticsearch\
**Created:** [April 23, 2019, 8:39pm UTC](https://discuss.elastic.co/t/parents-with-distinct-children/178112 "2019-04-23T20:39:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hatguesswho](https://avatars.discourse-cdn.com/v4/letter/h/96bed5/32.png) [@hatguesswho](https://discuss.elastic.co/u/hatguesswho)\
**Post date:** [April 23, 2019, 8:39pm UTC](https://discuss.elastic.co/t/parents-with-distinct-children/178112/1 "2019-04-23T20:39:06Z")

</div>

An example of the data.  
{  
"\_index": "act",  
"\_type": "\_doc",  
"\_id": "2389939",  
"\_score": 1,  
"\_source": {  
"photo\_id": "2389939",  
"family": [  
{  
"member\_id": "3079805",  
"member\_detail\_type\_id": "343 350 351 368 370 373 377 384 642 717 723 815"  
},  
{  
"member\_id": "3079807",  
"member\_detail\_type\_id": "343 347 354 369 377 637 717 723 797 935"  
}  
]  
}  
},  
{  
"\_index": "act",  
"\_type": "\_doc",  
"\_id": "1302788",  
"\_score": 1,  
"\_source": {  
"photo\_id": "1302788",  
"family": [  
{  
"member\_id": "586908",  
"member\_detail\_type\_id": "343 347 352 362 384 634 717"  
},  
{  
"member\_id": "586909",  
"member\_detail\_type\_id": "243 247 252 283 662 798 936"  
}  
]  
}  
},  
{  
"\_index": "act",  
"\_type": "\_doc",  
"\_id": "1327646",  
"\_score": 1,  
"\_source": {  
"photo\_id": "1327646",  
"family": [  
{  
"member\_id": "638315",  
"member\_detail\_type\_id": "343 347 361 362 373 384 667 669 717 815"  
}  
]  
}  
},  
{  
"\_index": "act",  
"\_type": "\_doc",  
"\_id": "1420554",  
"\_score": 1,  
"\_source": {  
"photo\_id": "1420554",  
"family": [  
{  
"member\_id": "921081",  
"member\_detail\_type\_id": "344 350 353 355 362 373 426 433 441 815"  
},  
{  
"member\_id": "921082",  
"member\_detail\_type\_id": "243 244 250 263 333 650 758"  
},  
{  
"member\_id": "921083",  
"member\_detail\_type\_id": "343 347 354 373 426 441 635 642 717 815"  
},  
{  
"member\_id": "921084",  
"member\_detail\_type\_id": "243 250 254 263 266 274 758 798"  
}  
]  
}  
}

A collection of family photos. Each photo has at least one person in the photo. Each person in the photo has characteristics represented by member\_detail\_type\_id. These are not unique, every member in the photo can have them. Currently the family data is nested. If i want to find a photo of a tall person or a tall person that is wearing a hat, I can pull that without any problems. However, if I want person A (tall, with hat -- 717, 347) but I also want person b (tall, with sunglasses -- 717 815) i have no idea how to bring back just those results.

I understand how to do them separately, however, how would I join(?) intersect(?) my results so that I only have the IDs of the photos that are in both sets? Also, how can i be certain that when searching for two people, I actually have two people, not one person that matches both criteria?

Is this possible? Is it possible with different data/ multiple indices?

---

<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:** [May 21, 2019, 8:39pm UTC](https://discuss.elastic.co/t/parents-with-distinct-children/178112/2 "2019-05-21T20:39:08Z")

</div>

Closed on May 21, 2019, 8:39pm UTC

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