我正在使用边缘ngram分析器。在检查字段的analyze API时,我得到以下结果。
例如对于查询" galaxy j7",它被分析为。
["g","ga","gal","gala","galax","galaxy","j","j7"]
我希望如下分析数据。
["g","ga","gal","gala","galax","galaxy","galaxy j","galaxy j7"]
这怎么可能?
索引中的设置如下。
{
"analysis": {
"filter": {
"autocomplete_filter": {
"type": "edge_ngram",
"min_gram": "1",
"max_gram": "20"
}
},
"analyzer": {
"autocomplete_analyzer": {
"filter": ["lowercase", "autocomplete_filter"],
"type": "custom",
"tokenizer": "standard"
}
}
}
}
并且字段的映射在下面。
{
"title_suggest": {
"type": "string",
"index_analyzer": "autocomplete_analyzer",
"search_analyzer": "standard",
"search_quote_analyzer": "autocomplete_analyzer"
}
}
答案 0 :(得分:1)
您需要使用edgeNGram tokenizer,而不是edge_ngram过滤器:
{
"analysis": {
"tokenizer": {
"autocomplete_tokenizer": {
"type": "edgeNGram",
"min_gram": "1",
"max_gram": "20"
}
},
"analyzer": {
"autocomplete_analyzer": {
"filter": ["lowercase"],
"type": "custom",
"tokenizer": "autocomplete_tokenizer"
}
}
}
}