Sunday, 9 February 2014
ElasticSearch Highlighting
ElasticSearch Highlighting (Postings Highlighter)
ElasticSearch Highlighting (Force Highlighter Type)
ElasticSearch Highlighting (Fast vector highlighter)
ElasticSearch Highlighting (Highlighted Fragments)
Force Highlighter Type
Allows to highlight search results on one or more fields. The implementation uses either the lucene highlighter,fast-vector-highlighter or postings-highlighter.The following is an example that forces the use of the plain highlighter,
POST method:
http://localhost:9200/products/_search/?pretty=true
{
"query": {
"query_string": {
"query": "lumia"
}
},
"highlight": {
"pre_tags": ["<b>"],
"post_tags": ["</b>"],
"fields": {
"name" : {"type" : "plain"}
}
}
}
Results:
{
"took": 100,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"hits": {
"total": 3,
"max_score": 1.304719,
"hits": [
{
"_index": "products",
"_type": "mobiles",
"_id": "10",
"_score": 1.304719,
"_source": {
"name": "nokia lumia 625"
},
"highlight": {
"name": [
"nokia <b>lumia</b> 625"
]
}
},
{
"_index": "products",
"_type": "mobiles",
"_id": "8",
"_score": 1.304719,
"_source": {
"name": "nokia lumia 510"
},
"highlight": {
"name": [
"nokia <b>lumia</b> 510"
]
}
},
{
"_index": "products",
"_type": "mobiles",
"_id": "9",
"_score": 1.304719,
"_source": {
"name": "nokia lumia 520"
},
"highlight": {
"name": [
"nokia <b>lumia</b> 520"
]
}
}
]
}
}
NOTE: I am using firefox rest client to run this example.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment