我試圖根據標題(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")
創建自動完成建議。Elasticsearch自動完成 - 從點和空白完成建議匹配輸入
映射情況如下:
{
"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"
}
}
}
我期望得到的建議獵人遊戲,查詢az.com.hsz.hunter.game
或Hunter Game
,它可以是標題或包裝nam即但是對於輸入爲"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
。
它是如何工作的?