# Which index(element) of an array are the ones that matched in highlight search results?

**URL:** <https://discuss.elastic.co/t/which-index-element-of-an-array-are-the-ones-that-matched-in-highlight-search-results/74019>\
**Category:** Elasticsearch\
**Created:** [February 6, 2017, 7:40am UTC](https://discuss.elastic.co/t/which-index-element-of-an-array-are-the-ones-that-matched-in-highlight-search-results/74019 "2017-02-06T07:40:08Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [February 6, 2017, 10:15am UTC](https://discuss.elastic.co/t/which-index-element-of-an-array-are-the-ones-that-matched-in-highlight-search-results/74019/2 "2017-02-06T10:15:32Z")

</div>

> [@jjsuway](#):
>
> How can I know the array position (index) ?

You can't with a regular "flat" mapping of your data.  
[Depending on your data](https://discuss.elastic.co/t/porting-a-relational-structure-to-elasticsearch-nested-or-parent-child/32920/2) you might want to look at [nested docs] ([Nested datatype | Elasticsearch Guide [5.2] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/5.2/nested.html)) mappings - you can then use [inner hits](https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-request-inner-hits.html#nested-inner-hits) to retrieve and highlight the individual nested docs that match your search criteria.

---

_[View the full topic](https://discuss.elastic.co/t/which-index-element-of-an-array-are-the-ones-that-matched-in-highlight-search-results/74019)._
