I have indexed my data using few analyzers. Everything is fine. When I try to search the data using particular keyword, the analyzed result brings me the proper data. But the applied highlighter brings me only the exact matches.
For example, I've the indexed data like " a cat stalking a bird " so when I try to search " talking ", I see the above data appear in the result but not in the highlighted field.
Settings
{
"index": {
"analysis": {
"analyzer": {
"summary_analyzer": {
"type": "custom",
"char_filter": "html_strip",
"tokenizer": "standard",
"filter": ["standard",
"loweritem",
"mynGram"],
"stopwords": "_english_"
},
"my_ngram_analyzer": {
"type": "custom",
"tokenizer": "my_ngram_tokenizer",
"filter": ["standard",
"loweritem"],
"stopwords": "_english_"
},
"snowball_analyzer": {
"type": "snowball",
"language": "English",
"stopwords": "_english_"
},
"loweritem_analyzer": {
"type": "custom",
"tokenizer": "keyword",
"filter": ["loweritem"]
},
"shingle_analyzer": {
"type": "custom",
"tokenizer": "standard",
"filter": ["myShingle"]
},
"entityReverse": {
"type": "custom",
"tokenizer": "keyword",
"filter": "reverse"
}
},
"filter": {
"mynGram": {
"type": "nGram",
"min_gram": 2,
"max_gram": 50,
"token_chars": ["letter",
"digit",
"symbol",
"punctuation"]
},
"myShingle": {
"type": "shingle",
"min_shingle_size": 2,
"max_shingle_size": 2
}
},
"tokenizer": {
"my_ngram_tokenizer": {
"type": "nGram",
"min_gram": "2",
"max_gram": "50",
"token_chars": ["letter",
"digit",
"symbol",
"punctuation"]
}
}
}
}
}
Query
{
"from": 0,
"size": 15,
"query": {
"filtered": {
"query": {
"bool": {
"must": {
"nested": {
"query": {
"match": {
"items.isDeleted": {
"query": 0,
"type": "boolean"
}
}
},
"path": "items"
}
},
"should": [{
"nested": {
"query": {
"multi_match": {
"query": "talking",
"fields": ["items.itemTitle.raw^5",
"items.itemTitle.my_ngram_title^3.5",
"items.itemTitle.snowball_title^4",
"items.itemTitle.loweritem_title^4"],
"type": "phrase"
}
},
"path": "items"
}
},
{
"nested": {
"query": {
"multi_match": {
"query": "talking",
"fields": ["itemSummary.summary.raw^1.5",
"itemSummary.summary.analyzed_summary^0.5",
"itemSummary.summary.snowball_summary"],
"type": "phrase"
}
},
"path": "itemSummary"
}
},
{
"match": {
"items.itemId": {
"query": "talking",
"type": "boolean"
}
}
}],
"minimum_should_match": "2"
}
},
"filter": {
"or": {
"filters": [{
"term": {
"roles": 1
}
},
{
"term": {
"users": 327
}
}]
}
}
}
},
"fields": ["*",
"_source"],
"sort": [{
"items.isNotDraft": {
"order": "asc",
"mode": "min"
}
},
{
"_score": {
}
}],
"highlight": {
"fields": {
*: {
}
}
}
}