# Many-to-many associations modeling - nested objects vs parent/child relationship

**URL:** <https://discuss.elastic.co/t/many-to-many-associations-modeling-nested-objects-vs-parent-child-relationship/110939>\
**Category:** Elasticsearch\
**Created:** [December 9, 2017, 5:30pm UTC](https://discuss.elastic.co/t/many-to-many-associations-modeling-nested-objects-vs-parent-child-relationship/110939 "2017-12-09T17:30:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dikey94](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dikey94/32/25218_2.png) [@dikey94](https://discuss.elastic.co/u/dikey94)\
**Post date:** [December 9, 2017, 5:30pm UTC](https://discuss.elastic.co/t/many-to-many-associations-modeling-nested-objects-vs-parent-child-relationship/110939/1 "2017-12-09T17:30:32Z")

</div>

Hello everyone,  
I wonder which association model is better in my case.

I'm going to use ES to store information about customers and their cases. Each customer has 0-5 cases and each case is related to 0-5 customers (many-to-many). The number of customers and cases is growing up. The data will be frequently updated. Each model contains 20 fields (more or less). There are 2 search scenarios:

- find all cases with given characteristics associated with customers with the given features
- find all customers with given characteristics associated with cases with the given features

Not sure if two independent types is a good solution and I need an advice. Thanks.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [December 9, 2017, 5:44pm UTC](https://discuss.elastic.co/t/many-to-many-associations-modeling-nested-objects-vs-parent-child-relationship/110939/2 "2017-12-09T17:44:52Z")

</div>

Many to many is not supported in elasticsearch. Which means to me that you'll need to duplicate data.

Like:

```auto
PUT customer/doc/1
{
  "name": "foo",
  "cases": [ {
    "title": "my case 1"
  }
  ]
}

```

```auto
PUT case/doc/1
{
  "title": "my case 1",
  "customers": [ {
    "name": "foo"
  }
  ]
}

```

That said, I'm pretty sure a case belongs to a single customer so that might be much easier than that.

---

<div class="post-metadata">

**Author:** ![dikey94](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dikey94/32/25218_2.png) [@dikey94](https://discuss.elastic.co/u/dikey94)\
**Post date:** [December 9, 2017, 6:00pm UTC](https://discuss.elastic.co/t/many-to-many-associations-modeling-nested-objects-vs-parent-child-relationship/110939/3 "2017-12-09T18:00:04Z")

</div>

That's what I thought. Thank you.

---

<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:** [January 6, 2018, 6:00pm UTC](https://discuss.elastic.co/t/many-to-many-associations-modeling-nested-objects-vs-parent-child-relationship/110939/4 "2018-01-06T18:00:46Z")

</div>

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