# Advice on cross field lookup

**URL:** <https://discuss.elastic.co/t/advice-on-cross-field-lookup/99022>\
**Category:** Elasticsearch\
**Created:** [August 31, 2017, 3:29pm UTC](https://discuss.elastic.co/t/advice-on-cross-field-lookup/99022 "2017-08-31T15:29:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![capaneus](https://avatars.discourse-cdn.com/v4/letter/c/41988e/32.png) [@capaneus](https://discuss.elastic.co/u/capaneus)\
**Post date:** [August 31, 2017, 3:29pm UTC](https://discuss.elastic.co/t/advice-on-cross-field-lookup/99022/1 "2017-08-31T15:29:15Z")

</div>

Hi,  
I have 2 document types,  
Doc type 1 stores all information of each problem:  
{  
...  
'\_type': 'problems'  
assignto: userabc,  
reportby: usercde

```
...

```

}

Doc type 2 stores how users are grouped into different groups:  
{ \_type: 'user\_group'  
'groupname': 'group a'  
'names': 'userabc', 'userddd', 'userbcd', ...]  
}  
{ \_type: 'user\_group'  
'groupname': 'group b'  
'names': 'userabc', 'usercde', 'userbcd', ...]  
}  
the same user can be existing in different groups

Is there way to filter issues by groups,  
eg, listing all the issues in group a, or stat issues count in group a

It would be ok to restructure the data, but I found it difficult to justify usergroup type is a child of problem type. Would anyone be able to help me on this?

---

<div class="post-metadata">

**Author:** ![capaneus](https://avatars.discourse-cdn.com/v4/letter/c/41988e/32.png) [@capaneus](https://discuss.elastic.co/u/capaneus)\
**Post date:** [September 11, 2017, 10:28am UTC](https://discuss.elastic.co/t/advice-on-cross-field-lookup/99022/2 "2017-09-11T10:28:18Z")

</div>

Hi dear community,  
Is there anyone can help me on this issue? It's quite blocking so far. Thanks a lot!  
It's a one-Many relationship, which means I will have many user groups with people assigned to multiple groups, but for reporter or assignee, there will be only one people assigned.

---

<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 11, 2017, 6:28pm UTC](https://discuss.elastic.co/t/advice-on-cross-field-lookup/99022/3 "2017-09-11T18:28:14Z")

</div>

there is support for [parent-child relationships](https://www.elastic.co/guide/en/elasticsearch/reference/5.5/mapping-parent-field.html) in Elasticsearch. Have you seen that and if so, does that fit your model or do you think it does not?

---

<div class="post-metadata">

**Author:** ![capaneus](https://avatars.discourse-cdn.com/v4/letter/c/41988e/32.png) [@capaneus](https://discuss.elastic.co/u/capaneus)\
**Post date:** [September 12, 2017, 3:34pm UTC](https://discuss.elastic.co/t/advice-on-cross-field-lookup/99022/4 "2017-09-12T15:34:03Z")

</div>

Hi Alexander,  
Thanks for the reply, I checked the doc and because each child need to specify its parent, I don't feel it will work in my case. I uploaded a diagram of the data strucuture. If you have any suggestions or how to apply this with parent child relationship, it will be very appreciated.

 ![relationship](https://us1.discourse-cdn.com/elastic/original/3X/4/b/4b51be7d907a02a9e869672194f84410cd5589d2.png)  
Both Doc type are under same index  
The result I wish to get is when I filter with group A, it give me Ticket 1, when I filter with group B, it gives me Ticket 1 and Ticket 2  
Thanks!

---

<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 10, 2017, 3:34pm UTC](https://discuss.elastic.co/t/advice-on-cross-field-lookup/99022/5 "2017-10-10T15:34:34Z")

</div>

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