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

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.

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

Like:

PUT customer/doc/1
{
  "name": "foo",
  "cases": [ {
    "title": "my case 1"
  }
  ]
}
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.

That's what I thought. Thank you.

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