Eğer sorgu sonucunda aranan kelimeleri vurgulamak isterseniz, aşağıdaki örneği kullanabilirsiniz. Daha fazla bilgi için Highlighting ve Highlighting Our Searches sayfalarını okuyabilirsiniz.


Sorgu


Bu örnek mevcut olan diğer seçeneklere göre daha yavaş olabilecek "Plain highlighter" seçeneği kullanıyor, o nedenle kendiniz için en uygun olanını bulmak isterseniz, yukarıdaki linkleri ziyaret edin.


curl -XGET "http://127.0.0.1:9203/_search?post_dev" -d'
{
"query": {
"match": {
"title": {
"query": "Title"
}
}
},
"highlight": {
"pre_tags": [
"<em>"
],
"post_tags": [
"</em>"
],
"tags_schema": "styled",
"fields": {
"title": {

}
}
},
"sort": [
{
"_score": {
"order": "asc"
}
}
],
"from": "0",
"size": "10"
}'

Sonuç


{
"took": 6,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 2206,
"max_score": null,
"hits": [
{
"_index": "post_dev",
"_type": "post",
"_id": "9",
"_score": 1.1041983,
"_source": {
"id": 9,
"title": "Title 3",
"description": "Desc 2"
},
"highlight": {
"title": [
"<em class=\"hlt1\">Title</em> 3"
]
},
"sort": [
1.1041983
]
},
{
"_index": "post_dev",
"_type": "post",
"_id": "30",
"_score": 1.1041983,
"_source": {
"id": 30,
"title": "Title 2",
"description": "Desc 2",

},
"highlight": {
"title": [
"<em class=\"hlt1\">Title</em> 2"
]
},
"sort": [
1.1041983
]
}
}
}
}