Highlights in nested list (NEST client)

I'm working with a large index of emails (using the Enron dataset here for testing). I’ve got highlights working in the Subject line of the email, but I’m also wanting to display highlights in custodian names (nested property type in the mapping). I can get results and highlights, but I can’t figure out how to tie them into the return value. Example…

Email object from the index:

{
  "subject": "FW: The Stranger...",
  "custodians": [
  {
    "displayName": "",
    "emailAddress": "rufino.doroteo@enron.com",
    "routeType": 0
  },
  {
    "displayName": "",
    "emailAddress": "dana.davis@enron.com",
    "routeType": 1
  },
  {
    "displayName": "",
    "emailAddress": "rebecca.sanchez@enron.com",
    "routeType": 1
  },
  {
    "displayName": "",
    "emailAddress": "simone.rose@enron.com",
    "routeType": 1
  },
  {
    "displayName": "",
    "emailAddress": "marilyn.rivera@enron.com",
    "routeType": 1
  }
],
"messageId": 48695,
"messageDate": "2000-11-15T13:06:00Z",
"compressedSize": 1595
}

This object is equal to results.Hits[0].Source for instance, and I also have the result.Hits[0].Highlights object containing highlights. If result.Hits[0].Highlights[0].Key == “custodians.emailAddress”, then result.Hits[0].Highlights[0].Value == “<tag>simone</tag>.<tag>rose</tag>@enron.com”. But I have several custodians in this message and I don’t see any way to tie this particular highlight to one particular custodian for replacement without doing something crazy like…

results.Hits[0].Source.Where(msg => msg.Custodians.Where(cust => cust.emailAddress == “simone.rose”));

Is there a way to get Elasticsearch to insert highlights “in place” where they’re supposed to be, or does this have to be handled in code after the search is performed? If it has to be handled in code, how the heck do you get the highlight into place of the Source?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.