首页 > 解决方案 > ElasticSearch:升级 Chewy/ElasticSearch 版本时出错

问题描述

我一直在我的 rails 应用程序中使用 gem咀嚼,在 ElasticSearch 中创建索引和搜索。之前我用的是elasticsearch 5.6版本,现在想升级到7.7。当我尝试创建索引时,出现以下错误。我正在使用的升级版耐嚼5.1.0

Elasticsearch::Transport::Transport::Errors::BadRequest: [400] {"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"Root mapping definition has unsupported parameters:  [country : {value={}}] [city : {value={}}] [state : {value={}}]"}],"type":"mapper_parsing_exception","reason":"Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters:  [country : {value={}}] [city : {value={}}] [state : {value={}}]","caused_by":{"type":"mapper_parsing_exception","reason":"Root mapping definition has unsupported parameters:  [country : {value={}}] [city : {value={}}] [state : {value={}}]"}},"status":400}

但是,它在 5.6 中运行得非常好。我试图在耐嚼中找到任何更改日志,但找不到任何更改日志。请帮助我了解问题出在哪里。谢谢

标签: elasticsearchruby-on-rails-5elasticsearch-mappingchewy-gem

解决方案


正如 Elastic Search Ninja 所建议的那样,这是由于在最新版本的 elasticsearch 中删除了类型。

截至今天(2020 年 10 月 19 日),Chewy 不支持 7.x 或 6.x

参考: https ://github.com/toptal/chewy/issues/609和 https://github.com/toptal/chewy/issues/673

推荐使用 ES 官方的 ruby​​ 或 rails 标准包。 https://github.com/elastic/elasticsearch-rubyhttps://github.com/elastic/elasticsearch-rails


推荐阅读