Find offset of matched input query terms to the document

I have explored elasticsearch and couldn't find how to get those terms in input query which matched an indexed document. Some times the query is itself big and we want to highlight and get offset of terms in the input query.

example : I have a query like "I love blue fox". The document which I indexed in elastic search contains "Black and Brown fox are animals".
My requirement is to get offsets of matching tokens in the input query. for example in this case from "I love blue fox" fox is matching to one document. How can I get offsets of query terms which matched the document.

The offset of fox in my query term is 12 which is what I need along with the matching token.

Is this solvable in elastic search?

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