在MultiSearch查询中使用Nest Phrase Suggester

时间:2014-09-08 20:12:09

标签: elasticsearch nest search-suggestion

我有多种类型的MultiSearch查询,每种类型有多个字段。我看到我可以将.SuggestPhrase()添加到单个字段上的单个SearchDescriptor,但不添加到整个搜索查询。如何将短语建议应用于多重查询?理想情况下,它将应用于正在搜索的所有字段。

我的用例是:用户执行MultiSearch查询。他们没有找到他们想要的东西。在这一点上,我想建议一个可能是他们正在寻找的不同查询。这与谷歌的“你是不是......”的推荐相似。

1 个答案:

答案 0 :(得分:1)

这是一个建议示例。

{
  "suggest": {
    "did-you-mean": {
      "text": "pizaz",
      "phrase": {
        "field": "your-field-that-has-the-phrases-to-suggest-to",
        "direct_generator": [
          {
            "field": "your-field-that-has-the-phrases-to-suggest-to",
            "suggest_mode": "always",
            "post_filter": "standard"
          }
        ]
      }
    },
    "did-you-mean-field2": {
      "text": "piza",
      "phrase": {
        "field": "your-field-that-has-the-phrases-to-suggest-to-field2",
        "direct_generator": [
          {
            "field": "your-field-that-has-the-phrases-to-suggest-to-field2",
            "suggest_mode": "always",
            "post_filter": "standard"
          }
        ]
      }
    }
  }
}