I'm trying to get highlights returned in results when I do a query with some highlights. I'm using Elasticsearch 2.2. Here's the query + results that I've tried so far:
curl -X GET http://localhost:9200/teg_test_news/_search -d '{
"query": {
"match": {
"_all": {
"query": "Lorem",
"operator":"and"
}
}
},
"highlight": {
"pre_tags": ["<span class=\"match\">"],
"post_tags": ["</span>"],
"fields": {
"title": {},
"body": {}
}
},
"_source": true
}'
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 0.10848885,
"hits": [
{
"_index": "teg_test_news",
"_type": "news",
"_id": "1",
"_score": 0.10848885,
"_source": {
"id": "1",
"title": "Bob's Bikes to open new store in Lorem",
"body": "\nLorem Ipsum\n\n"
}
}
]
}
}
As you can see, the hit returned does not have any highlights.
However, when I use Elasticsearch 1.7 I am getting highlights:
{
"took": 2,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 0.10848885,
"hits": [
{
"_index": "teg_test_news",
"_type": "news",
"_id": "1",
"_score": 0.10848885,
"_source": {
"id": "1",
"title": "Bob's Bikes to open new store in Lorem",
"body": "\nLorem Ipsum\n\n"
},
"highlight": {
"title": [
"Bob's Bikes to open new store in <span class=\"match\">Lorem</span>"
],
"body": [
"\n<span class=\"match\">Lorem</span> Ipsum\n\n"
]
}
}
]
}
}
What do I need to change here so that I get highlights returned in hits in Elasticsearch 2.2?