OpenSearch/docs/reference/migration/migrate_2_0/parent_child.asciidoc

44 lines
1.3 KiB
Plaintext
Raw Normal View History

=== 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.
It wasn't always faster than the `has_child` query and the was usually
inaccurate. The total hits and any aggregations in the same search request
would be incorrect if `top_children` was used.