小编Ins*_*Ins的帖子

弹性搜索完成建议多场

我正试图从多字段中获取建议.我找不到这样的例子,所以也许这不是最好的主意,但我对你的意见很感兴趣.

制图:

POST /authors
    {
       "mappings": {
          "author": {
             "properties": {
                "name": {
                   "type": "multi_field",
                   "fields": {
                      "name": {
                         "type": "string",
                         "index": "analyzed"
                      },
                      "ac": {
                         "type": "completion",
                         "index_analyzer": "simple",
                         "search_analyzer": "simple",
                         "payloads": true
                      }
                   }
                }
             }
          }
       }
    }

数据:


POST /authors/author/1
    {
       "name": "Fyodor Dostoevsky"
    }

查询:

POST /authors/_suggest

    {
       "authorsAutocomplete": {
          "text": "fyodor",
          "completion": {
             "field": "name.ac"
          }
       }
    }

要求是:

  • 获取查询使用文本"fyodor"和"dostoevsky",此示例仅适用于"fyodor"
  • 可以过滤建议

任何想法我怎样才能实现这些?

elasticsearch search-suggestion

6
推荐指数
1
解决办法
1273
查看次数

标签 统计

elasticsearch ×1

search-suggestion ×1