2015-11-08 06:59:07 -05:00
|
|
|
[[breaking_20_parent_child_changes]]
|
2015-08-14 14:26:06 -04:00
|
|
|
=== 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:
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------
|
|
|
|
DELETE *
|
|
|
|
|
|
|
|
PUT my_index
|
|
|
|
{
|
|
|
|
"mappings": {
|
|
|
|
"my_parent": {},
|
|
|
|
"my_child": {
|
|
|
|
"_parent": {
|
|
|
|
"type": "my_parent" <1>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
--------------------------
|
|
|
|
<1> 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.
|
2015-11-03 22:46:37 -05:00
|
|
|
It wasn't always faster than the `has_child` query and the results were usually
|
2015-08-14 14:26:06 -04:00
|
|
|
inaccurate. The total hits and any aggregations in the same search request
|
|
|
|
would be incorrect if `top_children` was used.
|