We are working on updating this book for the latest version. Some content might be out of date.
All that is needed in order to establish the parent-child relationship is to
specify which document type should be the parent of a child type.
be done at index creation time, or with the
update-mapping API before the
child type has been created.
As an example, let’s say that we have a company that has branches in many cities. We would like to associate employees with the branch where they work. We need to be able to search for branches, individual employees, and employees who work for particular branches, so the nested model will not help. We could, of course, use application-side-joins or data denormalization here instead, but for demonstration purposes we will use parent-child.
All that we have to do is to tell Elasticsearch that the
employee type has
branch document type as its
_parent, which we can do when we create