In Chapter 3, Modeling Your Data and Document Relations, we described how to set the mapping and index parent-child documents. In this section, we will discuss how to query parent-child documents. To manage relationships in Elasticsearch, parent-child and nested mappings are provided. The difference between parent-child and nested is in how the documents are stored. The parent-child documents are costly while querying for the data, and nested documents are costly while indexing data. We discussed the differences in detail in Chapter 3, Modeling your data and Document Relations.
In the previous sections, we indexed product documents for the e-commerce store. In this section, we will use the parent-child relation to index the reviews for the products as the child documents. The product document is the parent document. A new review can...