I have a problem with highlighting, on a fuzzy search. The problem is the highlighting is a char to long.
See example below.
PUT test
{
"settings": {
"index": {
"analysis": {
"analyzer": {
"my_suggest": {
"type": "custom",
"tokenizer": "my_tokenizer",
"filter": [
"danish_stop",
"danish_stemmer",
"lowercase",
"remove_duplicates"
]
}
},
"filter": {
"danish_stemmer": {
"type": "stemmer",
"language": "danish"
},
"danish_stop": {
"type": "stop",
"stopwords": "_danish_"
}
},
"tokenizer": {
"my_tokenizer": {
"type": "edge_ngram",
"min_gram": 3,
"max_gram": 15,
"token_chars": [
"letter",
"digit"
]
}
}
}
}
},
"mappings": {
"properties": {
"title": {
"type": "text",
"fields": {
"suggest": {
"type": "text",
"analyzer": "my_suggest",
"fielddata": true
}
}
}
}
}
}
PUT test/_doc/1
{
"title": "affaldsregister",
}
PUT test/_doc/2
{
"title": "affaldsregulativ",
}
GET test/_search
{
"_source": "title",
"query": {
"match": {
"title.suggest": {
"query": "affaldsreg",
"fuzziness": 1
}
}
},
"highlight": {
"fields": {
"title.suggest": {
}
}
}
}
It will highlight the char after the 'g'. But if I remove the fuzziness, it highlights until 'g'.