We have a requirement that we need to retrieve parent fields inside the child document.
Actually we have a mapping for the index as below:
{
"mappings": {
"properties": {
"relation_type": {
"eager_global_ordinals": true,
"type": "join",
"relations": {
"user": "forum"
}
}
}
}
}
Parent and child relationship is maintained between user and forum. I need to retrieve the user(parents) data inside the forum(child).
For example - User doc
{
"hn": "handle",
"iu": "user-image-url",
"uId": "user-id",
"relation_type": {
"name": "user"
}
}
And forum doc -
{
"uId": "userId",
"pId": "postId",
"relation_type": {
"name": "forum",
"parent": "userID"
}
}
I need to write a query such that it retrieves user data(user image) inside child data. For example - below is the result I wanted in the forum(child) query result with iu(image URL) from the user.
{
"uId": "userId",
"pId": "postId",
"iu": "user image" //user image from user doc
"relation_type": {
"name": "forum",
"parent": "userID"
}
}
I have posted the same on the stack overflow forum. - https://stackoverflow.com/questions/62468004/retrive-parent-data-embeded-in-child-doc-from-elastic-search-index
Need to know if it is possible or not, if yes then how?