How to highlight stopwords only on an exact phrase match?

Is it possible to configure Elasticsearch to highlight stopwords in a phrase, but not to highlight stopwords which occur alone?

For example, I want to highlight "the lord of the rings", "rings", or "lord". But I don't want Elasticsearch to highlight "of" or "the" if they occur alone.

I am using english_stop analyzer in the index settings, so it does not highlight any stop words. But if I remove the english_stop analyzer, then it always highlight "of", "the" even when they occur alone.

"settings": {
"index": {
"analysis": {
"analyzer": {
"english": {
"filter": [
"standard",
"lowercase",
"english_stop",

I found this stackoverflow post. I tried to use highlight query, but it did not highlight at all.

The Lord of the Rings is an epic high-fantasy novel written by English author J. R. R. Tolkien. The story began as a sequel to Tolkien's 1937 fantasy novel The Hobbit, but eventually developed into a much larger work. Written in stages between 1937 and 1949, The Lord of the Rings is one of the best-selling novels

1 Like

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