Reputation: 2933
I'm having a really tough time spotting what's wrong with this query. I do get results for the query, but highlights are not included.
{
"query": {
"query_string": {
"query": "foo",
"default_operator":"AND"
}
},
"highlight":{
"fields": {
"title":{}
}
}
}
Upvotes: 0
Views: 76
Reputation: 529
I am guessing elasticsearch is matching _all for querystring query and hence is not highlighting. Try
{
"query": {
"query_string": {
"query": "title:foo",
"default_operator":"AND"
}
},
"highlight":{
"fields": {
"title":{}
}
}
}
Alternatively, you can specify default_field like this:
{
"query": {
"query_string": {
"query": "foo",
"default_field": "title",
"default_operator":"AND"
}
},
"highlight":{
"fields": {
"title":{}
}
}
}
Upvotes: 1