What is the parent-child relationship (join field) in Elasticsearch?

Answer

The join field allows you to define parent-child relationships between documents within the same index, enabling queries that span related document types. Unlike nested documents (which are separate hidden Lucene docs), parent and child documents are separate, individually updateable documents. A has_child query returns parent documents that have matching children, and a has_parent query returns children whose parent matches. The critical constraint is that parent and child documents must be on the same shard — enforce this by including the parent ID as the routing value when indexing children. Parent-child is useful for one-to-many relationships where children are updated frequently (e.g., a product catalog with frequently updated stock levels).