# If parent has multiple childs and child can also have multiple parents

**URL:** https://discuss.elastic.co/t/if-parent-has-multiple-childs-and-child-can-also-have-multiple-parents/43314
**Category:** Elasticsearch
**Created:** [March 2, 2016, 10:12pm UTC](https://discuss.elastic.co/t/if-parent-has-multiple-childs-and-child-can-also-have-multiple-parents/43314 "2016-03-02T22:12:44Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Jayant](https://avatars.discourse-cdn.com/v4/letter/j/ecb155/32.png) [@Jayant](https://discuss.elastic.co/u/Jayant)
#### Post date: [March 2, 2016, 10:12pm UTC](https://discuss.elastic.co/t/if-parent-has-multiple-childs-and-child-can-also-have-multiple-parents/43314/1 "2016-03-02T22:12:44Z")

</div>

Hi, I am new to elasticsearch and I read the other posts saying that Multiple parents for children are not supported by ES.

I have a case where the actual data which I want to search lies in the parent.

For example:

Account- parent having

Multiple Children behaviors could be- Entity, Document, Event.

Business - parent having

Multiple Children behaviors could be- Entity, Document

In this case, I will end up with n\*n relationships.

I just want to do a check whether Business is an entity or an event or a document. I do not want to retrieve any information from the child table and the same goes for Account type.

Is there a provision in ES to do the above thing?

Any help on this will be much appreciated.

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [March 2, 2016, 11:06pm UTC](https://discuss.elastic.co/t/if-parent-has-multiple-childs-and-child-can-also-have-multiple-parents/43314/2 "2016-03-02T23:06:20Z")

</div>

> [@Jayant](#):
>
> Hi, I am new to elasticsearch and I read the other posts saying that Multiple parents for children are not supported by ES.

That is correct.

> [@Jayant](#):
>
> I just want to do a check whether Business is an entity or an event or a document. I do not want to retrieve any information from the child table and the same goes for Account type.

Assuming that this is a simple tag/value in a doc, a filter would do.

---

<div class="post-metadata">

### Author: ![Jayant](https://avatars.discourse-cdn.com/v4/letter/j/ecb155/32.png) [@Jayant](https://discuss.elastic.co/u/Jayant)
#### Post date: [March 2, 2016, 11:36pm UTC](https://discuss.elastic.co/t/if-parent-has-multiple-childs-and-child-can-also-have-multiple-parents/43314/3 "2016-03-02T23:36:00Z")

</div>

Hi Mark, thanks for your reply!!

Moving ahead, I wrote a search query, which does the search over every Type which has the children of type "Event" and return the search results over that type. But this query did not return any results

```
GET Hunter/_search
{
   "from": 0,
   "size": 2147483647,
   "query": {
      "has_child": {
         "type": "Event",
         "query": {
            "query_string": {
               "fields": [
                  "Name_text"
               ],
               "query": "a*"
            }
         }
      }
   }
}

```

If I write the same query without the has\_child clause I got 40 hits. Where am I going wrong in this?  
Note: I did not add any data to the Event type. I just added the mapping for it.

---

<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 5, 2017, 11:11pm UTC](https://discuss.elastic.co/t/if-parent-has-multiple-childs-and-child-can-also-have-multiple-parents/43314/4 "2017-07-05T23:11:50Z")

</div>


