Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add document highlighter to percolate api #3574

Closed
martijnvg opened this Issue Aug 26, 2013 · 0 comments

Comments

Projects
None yet
1 participant
@martijnvg
Copy link
Member

commented Aug 26, 2013

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>"
            ]
         }
      }
   ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.