ElasticSearch 没有在字段 [field_name] 上声明类型 [search_as_you_type] 的处理程序

ElasticSearch No handler for type [search_as_you_type] declared on field [field_name]

我正在尝试使用 EslasticSearch 实现自动完成功能,并且我遵循了“随手搜索”文档:

https://www.elastic.co/guide/en/elasticsearch/reference/7.x/search-as-you-type.html#search-as-you-type

当我 运行 下面的映射查询时出现异常。

PUT my-index-000001
 {
  "mappings": {
  "properties": {
    "my_field": {
      "type": "search_as_you_type"
    }
   }
  }
 }

{
 "error": {
 "root_cause": [
   {
     "type": "mapper_parsing_exception",
     "reason": "No handler for type [search_as_you_type] declared on field [my_field]"
   }
 ],
"type": "mapper_parsing_exception",
"reason": "Failed to parse mapping [_doc]: No handler for type [search_as_you_type] declared on field [my_field]",
"caused_by": {
  "type": "mapper_parsing_exception",
  "reason": "No handler for type [search_as_you_type] declared on field [my_field]"
  }
 },
 "status": 400
}

是文档提供了错误的映射查询还是我做错了什么?

search_as_you_type类型字段是在7.2版本中引入的

由于您使用的是 elasticsearch 版本 5,因此出现以下错误

"reason": "No handler for type [search_as_you_type] declared on field [my_field]