I am finding issues with highlighting when searching on fields using its complete data.I have used custom analyzers and each field is stored as text and keyword.
I am using whitespace as search analyzer.
My custom analyzer is:
"analysis": {
"filter": {
"indexFilter": {
"type": "pattern_capture",
"preserve_original": "true",
"patterns": [
"([@,$,%,&,!,.,#,^,*]+)",
"([\\w,.]+)",
"([\\w,@]+)",
"([-]+)",
"(\\w+)"
]
}
},
"analyzer": {
"indexAnalyzer": {
"filter": [
"indexFilter",
"lowercase"
],
"tokenizer": "whitespace"
},
"searchAnalyzer": {
"filter": [
"lowercase"
],
"tokenizer": "whitespace"
}
}
My mapping file is :
"field": {
"type": "text",
"term_vector": "with_positions_offsets",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
},
"analyzer": "indexAnalyzer",
"search_analyzer": "searchAnalyzer"
}
My query is :
{
"from": 0,
"size": 24,
"query": {
"bool": {
"should": [
{
"multi_match": {
"query": "monkey business",
"type": "phrase",
"slop": "2",
"fields": []
}
}
],
"minimum_should_match": 1
}
},
"highlight": {
"type": "unified",
"fields": {
"*": {}
}
}
}
my highlight results are :
"highlight": {
"field.keyword": [
"<em>monkey business</em>"
],
"field": [
"<em>monkey</em> <em>business</em>"
]
}