2

我正在使用 elasticsearch 6.1 版本,我想使用其功能的“Suggester”。我已经以建议者所需的格式转储了数据。

我已经使用了这些查询。

PUT /hotels
{
 "mappings": {
"hotel" : {
  "properties" : {
   "name" : { "type" : "keyword" },
   "city" : { "type" : "keyword" },
   "name_suggest" : {
     "type" :     "completion"
   }
 }
 }
 }
 }

put hotels/hotel/1
{
"name" :         "Mercure Hotel Munich",
"city" :         "Munich",
"name_suggest" : "Mercure Hotel Munich"
  }

put /hotels/hotel/2
 {
  "name" :         "Hotel Monaco",
  "city" :         "Munich",
"name_suggest" : "Hotel Monaco"
 }

put /hotels/hotel/3
 {
  "name" :         "Courtyard by Marriot Munich City",
 "city" :         "Munich",
 "name_suggest" : "Courtyard by Marriot Munich City"
  }

然后我触发我的搜索查询

Post  http://localhost:9200/hotels/_search 
      {
        "suggest": {
        "name_suggest": {
             "text": "h",
           "completion": {
              "field": "name_suggest"
           }
      }
    }
 }

我得到输出结果。它只向我返回了“摩纳哥酒店”这两个数据,但它并不建议我“慕尼黑美居酒店”它有酒店。

我想要在我的建议结果集中我也尝试过“前缀”。

有没有人试过。请向我建议任何解决方案。

4

0 回答 0