How to retrieve a parent field when search hit occurs at its child field?

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.

Hi @Keshav_Melnad - Welcome to the community!

Would you be able to provide the Atlas search index definition used in this search?

Apologies as I am a bit confused here. However, to try get a better understanding - Are you successfully retrieving the document(s) you want but have the "“sktextsdata.content.line” field missing?

On an additional note, I noticed your $project stage attempts to project the field "sktextsdata.name" which I cannot see exists (although I do see "sktextsdata.id.name" instead). Is this expected?

If possible, could you advise what you are expecting as the output based off what search term(s)?

Looking forward to your reply.

Regards,
Jason