# Possible to Highlight Inner Hits in Percolate Query?

**URL:** <https://discuss.elastic.co/t/possible-to-highlight-inner-hits-in-percolate-query/91926>\
**Category:** Elasticsearch\
**Created:** [July 5, 2017, 2:31pm UTC](https://discuss.elastic.co/t/possible-to-highlight-inner-hits-in-percolate-query/91926 "2017-07-05T14:31:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![a\_l](https://avatars.discourse-cdn.com/v4/letter/a/9fc348/32.png) [@a\_l](https://discuss.elastic.co/u/a_l)\
**Post date:** [July 5, 2017, 2:31pm UTC](https://discuss.elastic.co/t/possible-to-highlight-inner-hits-in-percolate-query/91926/1 "2017-07-05T14:31:57Z")

</div>

In ES 5.4, can the percolate query do highlighting on inner\_hits?

The docs used to explicitly say no, but that was removed in the commit that replaced the Percolator with the percolate query so I'm hoping against hope the functionality is now there (in which case I'd love to see an example of how to do it).

[EDIT]

Re-reading what I wrote I should clarify that the docs used to say that inner\_hits queries were not compatible with the Percolator, and that I'm extrapolating the inability to highlight them from that.

---

<div class="post-metadata">

**Author:** ![mvg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mvg/32/98890_2.png) [@mvg](https://discuss.elastic.co/u/mvg)\
**Post date:** [July 7, 2017, 7:43am UTC](https://discuss.elastic.co/t/possible-to-highlight-inner-hits-in-percolate-query/91926/2 "2017-07-07T07:43:42Z")

</div>

The `percolate` query itself doesn't support the `inner_hits`. In theory you could specify a `percolate` query inside a `nested` query, however the `percolator` field mapper only allows one query to be specified per field. So that percolator field that would be defined inside a nested field can only contain a single query. This setup / configuration doesn't buy you much here and you better off just specifying the percolator field outside a nested field.

Just out of curiosity; what are trying to get out of using percolate query together with inner hits?

---

<div class="post-metadata">

**Author:** ![a\_l](https://avatars.discourse-cdn.com/v4/letter/a/9fc348/32.png) [@a\_l](https://discuss.elastic.co/u/a_l)\
**Post date:** [July 7, 2017, 8:18am UTC](https://discuss.elastic.co/t/possible-to-highlight-inner-hits-in-percolate-query/91926/3 "2017-07-07T08:18:32Z")

</div>

Thanks for the reply Martijn,

Our documents look a bit like

```
{
  id: 1,
  people: [
    { name: 'Alice', tags: ['CEO', 'Co-founder'] },
    { name: 'Bob', tags: ['CFO', 'Co-founder'] },
    ...
  ],
  ...
}

```

As new documents arrive (or existing ones get updated) we want to find ones which match user defined queries on people.names (which is fine), but we'd also like to be able to explain why each document matched the query: "You asked to be notified about Alice: Document 1 matched because it contains an Alice, who is CEO and Co-founder".

Querying docs with inner\_hits and highlights does the job, but we'd like to be able to use the percolate query instead.

---

<div class="post-metadata">

**Author:** ![mvg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mvg/32/98890_2.png) [@mvg](https://discuss.elastic.co/u/mvg)\
**Post date:** [July 10, 2017, 7:28am UTC](https://discuss.elastic.co/t/possible-to-highlight-inner-hits-in-percolate-query/91926/4 "2017-07-10T07:28:13Z")

</div>

I see. This is currently not possible. The percolator could apply inner hits if the stored percolate query has a nested query with inner hits set. This sounds possible and looks like a nice feature.

---

<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:** [August 7, 2017, 7:28am UTC](https://discuss.elastic.co/t/possible-to-highlight-inner-hits-in-percolate-query/91926/5 "2017-08-07T07:28:28Z")

</div>

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