我正在尝试根据标题(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
}
}
}
}
}
}
带有Suggestion String的文档是:
{
"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"
}
}
}
我希望得到建议猎人游戏,查询az.com.hsz.hunter.game
或Hunter Game
,这可以是标题或包名。但对于输入为"input": "[az.com.hsz.hunter.game, Hunter Game]"
的文档,第一个输入值az.com.hsz.hunter.game
的预期suggetion不是第二个Hunter Game
。
如果输入被撤消"input": "[Hunter Game, az.com.hsz.hunter.game]"
建议适用于Hunter Game
,但不适用于az.com.hsz.hunter.game
。
如何使其有效?
答案 0 :(得分:0)
我认为你意外地将输入作为整个字符串而不是字符串列表。
"input": ["az.com.hsz.hunter.game", "Hunter Game"]
会奏效。
当前"[az.com.hsz.hunter.game, Hunter Game]"
被认为是一个字符串,因此您可以根据第一个字符获取结果。