弹性搜索自动完成 - 点对点的完成建议空格匹配输入 [英] Elasticsearch Autocomplete - Completion suggestion from dot & whitespace for matching input

查看:148
本文介绍了弹性搜索自动完成 - 点对点的完成建议空格匹配输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试基于标题(字符串为猎人游戏,猎人,猎人游戏,猎人游戏)创建自动完成建议。和包名称(字符串为az.com.hsz.hunter.game,az.com.hsz.hunter-game,az.com.hsz.hunter_game,az.com .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.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
          }
        }
      }
    }
  }
}

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

Document with Suggestion String is:

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

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

如何使其工作?

推荐答案

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

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

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

将工作。

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

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

这篇关于弹性搜索自动完成 - 点对点的完成建议空格匹配输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆