Reputation: 270
Is it possible to configure Elasticsearch not to highlight stopwords which occur alone in the text ?
For example in the following text from Wikipedia, 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.
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 ever written, with over 150 million copies sold. The title of the novel refers to the story's main antagonist, the Dark Lord Sauron, who had in an earlier age created the One Ring to rule the other Rings of Power as the ultimate weapon ...
Upvotes: 2
Views: 815
Reputation: 14227
You are looking for highlight_query:
highlight_query
to search with The Lord of the Rings and no stop words from 1.maybe like:
GET /_search
{
"query" : {
"match": {
"my_field": {
"query": "The Lord of the Rings"
}
}
},
"highlight" : {
"order" : "score",
"fields" : {
"my_field" : {
"highlight_query": {
"bool": {
"should": {
"match_phrase": {
"content": {
"query": "my words"
}
}
}
}
}
}
}
}
}
Upvotes: 1