Elasticsearch supports highlighting the parts of the response that caused the match. In the following query, the matches in the product_name field are highlighted:
#Highlighting
POST chapter7/_search
{
"query": {
"match": {
"product_name": {
"query": "samsung"
}
}
},
"highlight": {
"fields" : {
"product_name" : {}
}
}
}
The response to the preceding query is as follows:
{
....
"hits": {
"total": 2,
"max_score": 0.7590336,
"hits": [
{
"_index": "chapter7",
"_type": "product",
"_id": "AVsC7GDlF21JdiUIl1Q-",
"_score": 0.7590336,
"_source"...