Managing a child document
In the previous recipe, you saw how it's possible to manage relationships between objects with the nested object type. The disadvantage of using nested objects is their dependency on their parent. If you need to change the value of a nested object, you need to reindex the parent (this brings about a potential performance overhead if the nested objects change too quickly). To solve this problem, ElasticSearch allows you to define child documents.
Getting ready
You need a working ElasticSearch cluster.
How to do it...
You can modify the mapping of the order
example from the Mapping a document recipe by indexing the items as separate child documents.
You need to extract the item
object and create a new type of document item with the _parent
property set:
{ "order": { "properties": { "id": { "type": "string", "store": "yes", "index": "not_analyzed" }, "date": { "type": "date", "store": "no", "index":...