OpenSearch/docs/reference/query-dsl/parent-id-query.asciidoc
Martijn van Groningen b9dc5acf2c Cleanup ParentFieldMapper:
* Remove remaining 1.x bwc logic.
* Stop storing stored fields and indexed terms. The _parent field's only purpose is to support joins between parent and child type and only storing doc values is sufficient.
* In the mapping the parent field mapper is now known under '{parent}#{child}' key, because this is the field the parent/child join uses too.
* Added new sub fetch phase to lookup that _parent field from doc values field if that is required (before this was fetched from stored _parent field)
* Removed the ability to query directly on `_parent` in the query dsl. Instead the `{parent}#{child}` field should be used. Under the hood a doc values query is used instead of a term query, because only doc values fields are stored now.
* Added a new `parent_id` query to easily query child documents with a specific parent id without having to know what join field to use
* Also in aggregations `_parent` field can't be used any more and `{parent}#{child}` field name should be used instead to aggregate directly on the _parent join field.
2016-01-20 16:56:22 +01:00

31 lines
807 B
Plaintext

[[query-dsl-parent-id-query]]
=== Parent Id Query
added[3.0.0]
The `parent_id` query can be used to find a child document pointing to a particular parent id.
The actual underlying Lucene field that is used to store to what parent id a child document is referring to
is determined by the child type's `_parent` field. This query helps by selecting the right field based
on the specified child type. Example:
[source,js]
--------------------------------------------------
{
"parent_id" : {
"type" : "blog_tag",
"id" : "1"
}
}
--------------------------------------------------
==== Parameters
This query has two required parameters:
[horizontal]
`type`::
The child type. This must be a type with `_parent` field.
`id`::
The required parent id select documents must referrer to.