修复 ElasticSearch 'No handler for type [int] declared on field ...'

问题:

你想在 ElasticSearch 中创建具有自定义映射的索引,但你看到类似这样的错误消息:

elasticsearch-error.txt
elasticsearch.exceptions.RequestError: RequestError(400, 'mapper_parsing_exception', 'No handler for type [int] declared on field [id]')

解决方案

你的映射可能如下所示

mapping-bad.json
"id": {
    "type":  "int"
}

在你的映射 properties 中。

这里的问题是 int:ElasticSearch 使用 integer 作为整数类型,而不是 int

为了修复此问题,将属性更改为

mapping-fixed.json
"id": {
    "type":  "integer"
}

并重试创建索引。


Check out similar posts by category: Databases, ElasticSearch