c0degeek
c0degeek

Reputation: 1

ElasticSearch - Multiple types sharing the same child type

I'm looking for some help with ElasticSearch involving multiple "parent" types sharing the same "child" type.

As a trivial example, let's say I have two parent types:

  1. blogEntry
  2. status

I'd like to have a single "comment" type which is a child of both "blogEntry" and "status", since users can comment on both blog entries and users' status updates.

Is this actually possible in ES?

Or, am I looking at this problem in the wrong way? Does parent-child make no sense here, and instead would I want to use nested objects?

Thanks!

Upvotes: 0

Views: 291

Answers (1)

Photon
Photon

Reputation: 190

This is not possible at the moment:

  • The parent child mapping does not allow to specify multiple parents
  • Lets say if you have 2 parents which are routed to different shards, which shard will the child document be routed to?

You could instead have one child as nested document to the parent and the more frequently changing one as an actual child referencing the parent type.

Upvotes: 0

Related Questions