Parent/Child changes

Parent/child has been rewritten completely to reduce memory usage and to execute has_child and has_parent queries faster and more efficient. The _parent field uses doc values by default. The refactored and improved implementation is only active for indices created on or after version 2.0.

In order to benefit from all the performance and memory improvements, we recommend reindexing all existing indices that use the _parent field.

Parent type cannot pre-exist

A mapping type is declared as a child of another mapping type by specifying the _parent meta field:

DELETE *

PUT my_index
{
  "mappings": {
    "my_parent": {},
    "my_child": {
      "_parent": {
        "type": "my_parent" 
      }
    }
  }
}

The my_parent type is the parent of the my_child type.

The mapping for the parent type can be added at the same time as the mapping for the child type, but cannot be added before the child type.

top_children query removed

The top_children query has been removed in favour of the has_child query. It wasn’t always faster than the has_child query and the results were usually inaccurate. The total hits and any aggregations in the same search request would be incorrect if top_children was used.