12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- [[query-dsl-parent-id-query]]
- === Parent Id Query
- added[5.0.0]
- The `parent_id` query can be used to find child documents which belong to a particular parent:
- [source,js]
- --------------------------------------------------
- {
- "parent_id" : {
- "type" : "blog_tag",
- "id" : "1"
- }
- }
- --------------------------------------------------
- The above is functionally equivalent to using the following
- <<query-dsl-has-parent-query, `has_parent`>> query, but performs
- better as it does not need to do a join:
- [source,js]
- --------------------------------------------------
- {
- "has_parent": {
- "type": "blog",
- "query": {
- "term": {
- "_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.
|