Search hit multi valued field - identify hit object- Proposing solution

A while back someone asked a the following question. [Pasted below]
I have a similar need where in search needs to happen on a field in a multi
valued object, but from the hit highlights I would like to identify which
object in the multi valued field got the match.

Past questions:

Say I have a multivalued field(student[studentid, name]) in my
document[1234] with the following values :


I search for 'alice' and I get hit for doc: 1234.

From the searchHit is it possible to retrieve the 'studentId' for
which i got the hit? [In this case '2' corresponding to alice]

Basically instead of just the hightlight fragments, would like to get back
additional fields (for example, a unique id associated with the field in
the multi valued object) included in the highlights results.

Thinking of extending highlights query syntax such that you can specify
additional decorator fields along with the field you want to highlight.
These fields and the values of the fields will then be included in
each highlight fragment. Say a Key/Value pair of FieldName and FieldValue
of all the additional data fields. That would allow one to include the "id"
field in my use case along with the hit highlights.

Let me know if it makes sense, so that I can go ahead and implement this
extension feature.

You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
For more options, visit