首页 > 解决方案 > ElasticSearch 没有在字段 [field_name] 上声明的类型 [search_as_you_type] 的处理程序

问题描述

我正在尝试使用 EslasticSearch 实现自动完成功能,并遵循 search-as-you-type 文档:

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
}

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

标签: elasticsearchelastic-stack

解决方案


search_as_you_typetype 字段是在 7.2 版本中引入的

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

“原因”:“没有在字段 [my_field] 上声明的类型 [search_as_you_type] 的处理程序


推荐阅读