Possible to Highlight Inner Hits in Percolate Query?

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.

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?

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.

1 Like

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.

1 Like

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