Parent/child relation / Self join of a collection ...
# community-help
o
Parent/child relation / Self join of a collection Is there a way to self join a collection to model parent child relations? An example would be for example a parent product being a "pack" with a an array referencing other products part of that pack. Or is there perhaps an alternative approach to model parent/child relations?
f
Hey @Olivier , Typesense does not support a true self-join inside a single collection. The join logic and examples are built around references between collections. So for a parent/child setup like a pack that contains other products, I would not model that as a self-join in Typesense. The usual approach is to keep products in one collection and represent the pack relationship separately, either with a packs collection that references products.id, or with a pack_items collection if you need item quantity, ordering, or other metadata. If the relationship is simple and you mostly need it for app-side rendering, storing parent_id or child_ids in the same collection can also work, with your application resolving the hierarchy after search.
👍 1