【问题标题】:Why does the elasticsearch suggesters return multiple equal objects?为什么弹性搜索建议器返回多个相等的对象?
【发布时间】:2017-03-03 14:40:46
【问题描述】:

我目前正在和建议者一起玩,想知道为什么结果集总是有多个相等的对象。

示例请求:

{"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

【问题讨论】:

  • 与 6.7 版相同。

标签: elasticsearch search-suggestion


【解决方案1】:

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

您必须添加跳过重复参数。

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

【讨论】:

    【解决方案2】:

    您是否尝试将有效负载添加到您的文档中?

    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
    }
    

    }'

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-15
      • 1970-01-01
      • 2021-05-15
      • 2019-07-12
      • 2021-03-06
      • 1970-01-01
      相关资源
      最近更新 更多