File tree Expand file tree Collapse file tree 1 file changed +23
-11
lines changed
Expand file tree Collapse file tree 1 file changed +23
-11
lines changed Original file line number Diff line number Diff line change 33
44added[5.0.0]
55
6- The `parent_id` query can be used to find a child document pointing to a particular parent id.
6+ The `parent_id` query can be used to find child documents which belong to a particular parent:
77
8- The actual underlying Lucene field that is used to store to what parent id a child document is referring to
9- is determined by the child type's `_parent` field. This query helps by selecting the right field based
10- on the specified child type. Example:
8+ [source,js]
9+ --------------------------------------------------
10+ {
11+ "parent_id" : {
12+ "type" : "blog_tag",
13+ "id" : "1"
14+ }
15+ }
16+ --------------------------------------------------
17+
18+ The above is functionally equivalent to using the following
19+ <<query-dsl-has-parent-query, `has_parent`>> query, but performs
20+ better as it does not need to do a join:
1121
1222[source,js]
1323--------------------------------------------------
1424{
15- "parent_id" : {
16- "type" : "blog_tag",
17- "id" : "1"
25+ "has_parent": {
26+ "type": "blog",
27+ "query": {
28+ "term": {
29+ "_id": "1"
30+ }
1831 }
32+ }
1933}
2034--------------------------------------------------
2135
@@ -24,8 +38,6 @@ on the specified child type. Example:
2438This query has two required parameters:
2539
2640[horizontal]
27- `type`::
28- The child type. This must be a type with `_parent` field.
41+ `type`:: The **child** type. This must be a type with `_parent` field.
2942
30- `id`::
31- The required parent id select documents must referrer to.
43+ `id`:: The required parent id select documents must referrer to.
You can’t perform that action at this time.
0 commit comments