IMPORTANT: No additional bug fixes or documentation updates
will be released for this version. For the latest information, see the
current release documentation.
Parent Id Queryedit
Added in 5.0.0.
The parent_id
query can be used to find child documents which belong to a particular parent.
Given the following mapping definition:
PUT /my_index { "mappings": { "blog_post": { "properties": { "name": { "type": "keyword" } } }, "blog_tag": { "_parent": { "type": "blog_post" }, "_routing": { "required": true } } } }
GET /my_index/_search { "query": { "parent_id" : { "type" : "blog_tag", "id" : "1" } } }
The above is functionally equivalent to using the following
has_parent
query, but performs
better as it does not need to do a join:
GET /my_index/_search { "query": { "has_parent": { "parent_type": "blog_post", "query": { "term": { "_id": "1" } } } } }
Parametersedit
This query has two required parameters:
|
The child type. This must be a type with |
|
The required parent id select documents must referrer to. |
|
When set to |