【发布时间】:2017-03-09 13:42:54
【问题描述】:
我正在尝试根据标题 (string as "Hunter Game", "Hunter", "HunterGame", "Hunter-Game") 和包名称 (string as "az.com.hsz.hunter.game", "az.com.hsz.hunter-game", "az.com.hsz.hunter_game", "az.com.hsz.hunterGame") 创建自动完成建议。
映射如下:
{
"app-search-test": {
"mappings": {
"package": {
"properties":
{"title": {
"type": "string",
"analyzer": "autocomplete"
},
"package_name": {
"type": "string"
},
"title-suggest": {
"type": "completion",
"analyzer": "simple",
"payloads": true,
"preserve_separators": false,
"preserve_position_increments": true,
"max_input_length": 50
}
}
}
}
}
}
带有建议字符串的文档是:
{
"title": "HUnter Game",
"package_name": "az.com.hsz.hunter.game",
"title-suggest": {
"output": "Hunter Game",
"input": "[az.com.hsz.hunter.game, Hunter Game]",
"payload": {
"package_name": "az.com.hsz.hunter.game",
"icon": "<some-url>",
"developer": "Vish",
"id": "az.com.hsz.hunter.game",
"title": "Hunter Game"
}
}
}
索引设置:
"analysis": {
"filter": {
"words_splitter": {
"type": "word_delimiter",
"preserve_original": "true",
"catenate_all": "true"
},
"ngram": {
"type": "ngram",
"min_gram": "2",
"max_gram": "15"
}
},
"analyzer": {
"autocomplete": {
"type": "custom",
"filter": [
"standard",
"lowercase",
"stop",
"kstem",
"ngram",
"words_splitter"
],
"tokenizer": "keyword"
}
}
}
我希望得到建议 Hunter Game,查询 az.com.hsz.hunter.game 或 Hunter Game,可以是标题或包名称。但是对于带有输入 "input": "[az.com.hsz.hunter.game, Hunter Game]" 的文档,获得第一个输入值 az.com.hsz.hunter.game 而不是第二个 Hunter Game 的预期建议。
如果输入颠倒了"input": "[Hunter Game, az.com.hsz.hunter.game]" 建议适用于Hunter Game,但不适用于az.com.hsz.hunter.game。
如何让它工作?
【问题讨论】:
标签: elasticsearch autocomplete lucene autosuggest search-suggestion