# Highlights in nested list (NEST client)

**URL:** <https://discuss.elastic.co/t/highlights-in-nested-list-nest-client/184054>\
**Category:** Elasticsearch\
**Created:** [June 3, 2019, 8:40pm UTC](https://discuss.elastic.co/t/highlights-in-nested-list-nest-client/184054 "2019-06-03T20:40:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bo.clifton](https://avatars.discourse-cdn.com/v4/letter/b/a6a055/32.png) [@bo.clifton](https://discuss.elastic.co/u/bo.clifton)\
**Post date:** [June 3, 2019, 8:40pm UTC](https://discuss.elastic.co/t/highlights-in-nested-list-nest-client/184054/1 "2019-06-03T20:40:31Z")

</div>

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`?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 1, 2019, 8:40pm UTC](https://discuss.elastic.co/t/highlights-in-nested-list-nest-client/184054/2 "2019-07-01T20:40:32Z")

</div>

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