Here, I created Atlas search index for the path “sktextsdata.content.words.word”. When there is a search hit of a certain word, how can I retrieve its parent node that is “sktextsdata.content.line” which is not included in path for not having any relevance? So far my code only retrieves the search results with “highlight” in the pipeline.
The document:
[{
"sktextsdata": [
{
"id": {
"name": "Tarkasangraha",
"poetry": "",
"presentation": "SC1:1",
"audioUrl": ["SC1:1", "SC1:2", "SC1:3", "SC1:4", "SC1:5"],
"content": [
{
"words": [
{
"begin": "0.000",
"end": "13.280",
"id": "f000001",
"word": "The author of Tarkasangraha is Annambhatta."
}
],
"line": "SC1:1-SC2:0_PCID:0_CID:1"
},
{
"words": [
{
"begin": "13.280",
"end": "22.240",
"id": "f000002",
"word": "Tarkasangraha deals with defining the elements of the world."
}
],
"line": "SC1:1-SC2:0_PCID:0_CID:2"
},
{
"words": [
{
"begin": "22.240",
"end": "31.920",
"id": "f000003",
"word": "It has 7 chapters."
}
],
"line": "SC1:1-SC2:0_PCID:0_CID:3"
}
]
}
}
]
}]
The pipleline:
let pipeline = [
{
'$search': {
"index": "skgallery",
'text': {
'query': query,
'path': 'sktextsdata.content.words.word',
'fuzzy': {
'maxEdits': 2,
'prefixLength': 4,
'maxExpansions': 1000
},
},
'highlight': {
'path':'sktextsdata.content.words.word',
"maxNumPassages": 1000
}
}
},
{
'$project': {
'_id': 1,
'resHighlights': {
'$meta': 'searchHighlights'
},
'score': {
'$meta': 'searchScore'
},
'sktextsdata.name': 1
}
}
]
Any help would be appreciated.