mongoosastic [mapper_parsing_exception]没有在字段[type]上声明的类型[string]的处理程序

时间:2018-01-06 10:04:43

标签: mongodb elasticsearch mongoosastic

这是错误

{ Error: [mapper_parsing_exception] No handler for type [string] declared on field [type]
    at respond (/home/jilu/Documents/project/backup/assignment_ok/node_modules/elasticsearch/src/lib/transport.js:289:15)
    at checkRespForFailure (/home/jilu/Documents/project/backup/assignment_ok/node_modules/elasticsearch/src/lib/transport.js:248:7)
    at HttpConnector.<anonymous> (/home/jilu/Documents/project/backup/assignment_ok/node_modules/elasticsearch/src/lib/connectors/http.js:164:7)
    at IncomingMessage.wrapper (/home/jilu/Documents/project/backup/assignment_ok/node_modules/elasticsearch/node_modules/lodash/lodash.js:4968:19)
    at emitNone (events.js:91:20)
    at IncomingMessage.emit (events.js:185:7)
    at endReadableNT (_stream_readable.js:974:12)
    at _combinedTickCallback (internal/process/next_tick.js:80:11)
    at process._tickCallback (internal/process/next_tick.js:104:9)
  status: 400,
  displayName: 'BadRequest',
  message: '[mapper_parsing_exception] No handler for type [string] declared on field [type]',

并且映射没有创建

请解释一下mongoosastic的配置。

我使用快速JS和MongoDb作为后端。

如果我正在接听电话搜索Api:

{
    "took": 1,
    "timed_out": false,
    "_shards": {
        "total": 5,
        "successful": 5,
        "skipped": 0,
        "failed": 0
    },
    "hits": {
        "total": 0,
        "max_score": null,
        "hits": []
    }
}

Hits数组为null,total为零,映射也显示为空。

1 个答案:

答案 0 :(得分:0)

我在设置Mongoosastic 4.3 + Elasticsearch 6.2之后遇到了同样的问题,问题是由于Mongoosastic与Elasticsearch 6.x的不兼容!!

如果你谷歌,你会发现Elasticsearch更改了&#39; string&#39;的默认类型。到&#39;文字&#39;及其记录的here。在帖子的最后,他们说:

  

尽管如此,您仍然应该考虑升级它们,因为我们计划在发布Elasticsearch 6.0时删除此向后兼容层。

我使用最新的Elasticsearch 6.2在Mongoosastic上发现了更多的不兼容性。我已提交pull request进行这些更改,但不确定何时/是否会被接受。在他们修复官方版本之前,我正在使用我的Mongoosastic克隆修复,直到他们修补官方版本。