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 Query
edit
IMPORTANT: This documentation is no longer updated. Refer to Elastic's version policy and the latest documentation.
Parent Id Query
editThe 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": {
"_doc": {
"properties": {
"my_join_field": {
"type": "join",
"relations": {
"my_parent": "my_child"
}
}
}
}
}
}
PUT my_index/_doc/1?refresh
{
"text": "This is a parent document",
"my_join_field": "my_parent"
}
PUT my_index/_doc/2?routing=1&refresh
{
"text": "This is a child document",
"my_join_field": {
"name": "my_child",
"parent": "1"
}
}
GET /my_index/_search
{
"query": {
"parent_id": {
"type": "my_child",
"id": "1"
}
}
}
Parameters
editThis query has two required parameters:
|
|
The child type name, as specified in the |
|
|
The ID of the parent document. |
|
|
When set to |