We have the documents in the index with user and the products
[{
"id": 10,
"type": "user",
"name": "John Smith",
"rating": 4,
"_childDocuments_": [
{
"id": 11,
"type": "product",
"title": "Phone"
},
{
"id": 12,
"type": "product",
"title": "Best phone"
}
]
},
{
"id": 20,
"type": "user",
"name": "Bill Brown",
"rating": 3,
"_childDocuments_": [
{
"id": 21,
"type": "product",
"title": "Best phone"
}
]
}]
On searching best phone
, how to retrieve child document + parent documents, ordered by search score?
Result should be something like
[{
"id": 10,
"type": "user",
"name": "John Smith",
"rating": 4,
"_childDocuments_": [
{
"id": 12,
"type": "product",
"title": "Best phone"
}
]
},
{
"id": 20,
"type": "user",
"name": "Bill Brown",
"rating": 3,
"_childDocuments_": [
{
"id": 21,
"type": "product",
"title": "Best phone"
}
]
},
{
"id": 10,
"type": "user",
"name": "John Smith",
"rating": 4,
"_childDocuments_": [
{
"id": 11,
"type": "product",
"title": "Phone"
}
]
}]
The problem is if we store user details in product document it will be hard to handle cases when user wants to update the name.