为什么elasticsearch建议者返回多个相等的对象?

问题描述 投票:1回答:2

我现在正在玩建议器,并想知道为什么结果集总是有多个相等的对象。

示例请求:

{"suggest": {
    "test" : {
        "text": "holz",
        "term" : {
            "field":"title"
        }
    }
}}

结果:

{"suggest": {
   "test": [
     {
        "text": "holz",
        "offset": 0,
        "length": 4,
        "options": [...]
     },
     {
        "text": "holz",
        "offset": 0,
        "length": 4,
        "options": [...]
     },
     {
        "text": "holz",
        "offset": 0,
        "length": 4,
        "options": [...]
     },
     {
        "text": "holz",
        "offset": 0,
        "length": 4,
        "options": [...]
     }
  ]
}}

甚至options中的物体也完全相同。无论我想要什么样的建议,它总是一样的。这有什么解释吗?

ES版本是2.3.4

elasticsearch search-suggestion
2个回答
1
投票

https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-completion.html#skip_duplicates

您必须添加skip duplicates参数。

丹尼尔,祝你有美好的一天


0
投票

您是否尝试过向您的文档添加有效负载?

https://www.elastic.co/guide/en/elasticsearch/reference/2.1/search-suggesters-completion.html

curl -X PUT 'localhost:9200/music/song/1?refresh=true' -d '{
"name" : "Nevermind",
"suggest" : {
    "input": [ "Nevermind", "Nirvana" ],
    "output": "Nirvana - Nevermind",
    **"payload" : { "artistId" : 2321 },**
    "weight" : 34
}

}'

© www.soinside.com 2019 - 2024. All rights reserved.