highlight does not properly work with exact phrase match search in elasticsearch

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

highlight does not properly work with exact phrase match search in elasticsearch

hamedhsn
This post has NOT been accepted by the mailing list yet.
I am having problem with highlighting the exact phrase search. when the highlight comes back it highlights all the terms regardless of the exact search. see the example:

Put /test2
PUT /test2/all/1
{
  "name" :         "climate behaviour change"
}
PUT /test2/all/3
{
  "name" :         "climate behaviour change it is climate change"
}
and when I run this query:

GET /test2/_search
{
  "query": {
    "query_string": {
      "fields": ["name"],
      "query": "\"climate change\""

 }
}
    ,"highlight": {
            "fields": {
            "name": {"number_of_fragments": 0}
                }
    }
}
the result is

"hits": [
      {
        "_index": "test2",
        "_type": "all",
        "_id": "3",
        "_score": 0.23013961,
        "_source": {
          "name": "climate behaviour change it is climate change"
        },
        "highlight": {
          "name": [
            "<em>climate</em> behaviour <em>change</em> it is <em>climate</em> <em>change</em>"
          ]
        }
      }
    ]
since I searched for exact climate change I would expect to have highlight for just the second part of the result, so climate behaviour change should not get highlighted. Does anyone know why this is like that? or any other way I can get what I want?