1
votes

When doing proximity search using match_phrase with 'slop', the highlight tags appear on each word separately so I cannot know where was the match.

For example, if I search for the phrase "quick fox" in the text "a quick brown fox" with slop=1, I will get the result with 'em' tags on "quick" and "fox" like that: quick brown fox

What I need is the entire "quick brown fox" emphasized, (connected from the first to the last found words, i.e. the sequence of words that satisfied the query).
To find it manually can be complicated when the match_phrase contains many words and found many times in the text. Is there any way to set elasticsearch to return this?

1

1 Answers

1
votes

Elasticsearch tokenizes both your document and your search (splitting it on space basically for the example you give). The match_phrase will make sure those search tokens are found in that order in your document tokens. The highlighter will then highlight each of those tokens. I think it would be very hard to do what you want solely with Elastiscearch.