-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Closed
Labels
Description
Add document highlighting to percolate api, that highlights for each matching percolator query snippets inside the document being percolated.
All highlight options that are supported via the search api are also supported in the percolate api. The size option is a required option if highlighting is specified in the percolate api.
Percolate highlight example
Index document:
curl -XPUT 'localhost:9200/my-index/_percolator/1' -d '{
"query": {
"match" : {
"body" : "brown fox"
}
}
}'Index second document:
curl -XPUT 'localhost:9200/my-index/_percolator/2' -d '{
"query": {
"match" : {
"body" : "lazy dog"
}
}
}'Percolate request:
curl -XGET 'localhost:9200/my-index/my-type/percolate' -d '{
"doc" : {
"body" : "The quick brown fox jumps over the lazy dog"
},
"highlight" : {
"fields" : {
"body" : {}
}
},
"size" : 5
}'Percolate response:
{
"took": 18,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"total": 2,
"matches": [
{
"_index": "my-index",
"_id": "1",
"highlight": {
"body": [
"The quick <em>brown</em> <em>fox</em> jumps over the lazy dog"
]
}
},
{
"_index": "my-index",
"_id": "2",
"highlight": {
"body": [
"The quick brown fox jumps over the <em>lazy</em> <em>dog</em>"
]
}
}
]
}