PUT test
{
"mappings": {
"properties": {
"my_field": {
"type": "search_as_you_type"
}
}
}
}
PUT test/_doc/1
{
"my_field": "quick brown fox jump lazy dog"
}
GET test/_search
{
"query": {
"multi_match": {
"query": "brown fox ",
"type": "bool_prefix",
"fields": [
"my_field",
"my_field._2gram",
"my_field._3gram"
]
}
},
"highlight": {
"fields": {
"my_field": {
"type" : "unified"
}
}
}
}
That leads to the result:
"hits" : [
{
"_index" : "test",
"_type" : "_doc",
"_id" : "1",
"_score" : 0.8630463,
"_source" : {
"my_field" : "quick brown fox jump lazy dog"
},
"highlight" : {
"my_field" : [
"quick <em>brown</em> <em>fox</em> jump lazy dog"
]
}
}
]
It will only highlight matching tokens — if you leave out the space after fox, it won't mark that. Are you expecting partial highlighting instead? Not sure this would make sense for an autocomplete / search as you type field.