Hi,
I have created a parent - child relationship between employee and address.
PUT my_index10
{
"mappings": {
"doc": {
"properties": {
"my_join_field": {
"type": "join",
"relations": {
"employee": "address"
}
}
}
}
}
}
PUT my_index10/doc/1?refresh
{
"id": "1",
"name": "John",
"age": "26",
"my_join_field": {
"name": "employee"
}
}
PUT my_index10/doc/2?refresh
{
"id": "2",
"name": "Watson",
"age": "25",
"my_join_field": {
"name": "employee"
}
}
PUT my_index10/doc/3?routing=1&refresh
{
"city": "NewYork",
"country": "USA",
"my_join_field": {
"name": "address",
"parent": "1"
}
}
PUT my_index10/doc/4?routing=1&refresh
{
"city": "Chicago",
"country": "USA",
"my_join_field": {
"name": "address",
"parent": "2"
}
}
GET my_index10/_search
{
"query": {
"match_all": {}
},
"sort": ["_id"]
}
I could get the fields of child (address) using the below query.
GET my_index10/_search
{
"query": {
"parent_id": {
"type": "address",
"id": "1"
}
},
"aggs": {
"parents": {
"terms": {
"field": "my_join_field#employee",
"size": 10
}
}
},
"script_fields": {
"parent": {
"script": {
"source": "doc['my_join_field#employee']"
}
}
}
}
Now I am supposed to get the fields and values of parent (employee) as well. How do I get that.
Any help would be appreciated.
Thanks in advance.