ES highlight question


(Xudong You) #1

I have a document like following:

{
"title": "the productivity is ...."
}

and I use ES built-in english analyzer on both index and query time.

When I search "product" with highlight on title field:

{
"query": {
"match": {
"Title": "product"
}},
"highlight":{"pre_tags":[""],"post_tags":[""],"fields":{"title":{}}}
}

I got the result that the productivity is highlighted:
"highlight": {
"Title": [
"the productivity is "
]
}

I understand that it is because with built-in english analyzer, the "productivity" is transformed to "product" in inverse index.

But is it possible to only highlight the exactly same text as the query term? That is, in my above example, I don't want productivity is highlighted.


(David Pilato) #2

I wonder if you can use in that case another query on a subfield which is not using the english analyzer and wrap it inside a highlight query? See https://www.elastic.co/guide/en/elasticsearch/reference/2.4/search-request-highlighting.html#_highlight_query


(Xudong You) #3

Thank!
So the ES by default with highlight the words as long as it match the query term in inverse index tokens ?

Adding highlight query works, my concern is, it may introduce performance issue?


(system) #4