弹性搜索自动完成

编程入门 行业动态 更新时间:2024-10-26 14:29:38
本文介绍了弹性搜索自动完成 - 点对点的完成建议空格匹配输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试基于标题(字符串为猎人游戏,猎人,猎人游戏,猎人游戏)创建自动完成建议。和包名称(字符串为az.hsz.hunter.game,az.hsz.hunter-game,az.hsz.hunter_game,az .hsz.hunterGame)。

I am trying to create auto-complete suggest based on title (string as "Hunter Game", "Hunter", "HunterGame", "Hunter-Game") and package name (string as "az.hsz.hunter.game", "az.hsz.hunter-game", "az.hsz.hunter_game", "az.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 } } } } } }

与建议字符串的文档是: / p>

Document with Suggestion String is:

{ "title": "HUnter Game", "package_name": "az.hsz.hunter.game", "title-suggest": { "output": "Hunter Game", "input": "[az.hsz.hunter.game, Hunter Game]", "payload": { "package_name": "az.hsz.hunter.game", "icon": "<some-url>", "developer": "Vish", "id": "az.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.hsz.hunter.game 或猎人游戏,它是由标题或包名称。但是对于输入input:[az.hsz.hunter.game,Hunter Game]的文档,获取预期的第一个输入值的含义 az.hsz.hunter.game 不与第二个猎人游戏。 如果输入被反转input:[Hunter Game,az.hsz.hunter.game]为猎人游戏,但不包含 az.hsz.hunter.game 。

I am expecting to get suggestion Hunter Game, for query az.hsz.hunter.game or Hunter Game, which is either by title or package name. But for document with input "input": "[az.hsz.hunter.game, Hunter Game]" , getting expected suggetion for first input value az.hsz.hunter.game not with second Hunter Game. If input is reversed "input": "[Hunter Game, az.hsz.hunter.game]" suggestion working for Hunter Game, but not with az.hsz.hunter.game.

如何使其工作?

推荐答案

我认为,您正在将输入整个字符串比较列表。

I think by accidently you are making input a whole string rather than list of strings.

"input": ["az.hsz.hunter.game", "Hunter Game"]

将工作。

code>[az.hsz.hunter.game,Hunter Game]被认为是一个字符串,因此您可以根据第一个字符返回结果。

currently "[az.hsz.hunter.game, Hunter Game]" is considered one string and hence you get back the result according to whatever is the first character.

更多推荐

弹性搜索自动完成

本文发布于:2023-11-30 00:30:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1648122.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自动完成   弹性

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!