ruby-on-rails - Rails 5.1 与 ElasticSearch 7.1 重建索引错误

标签 ruby-on-rails elasticsearch activerecord indexing ruby-on-rails-5.1

我在 Rails 5 控制台 上运行此命令时遇到一些问题。

:017 > User.reindex

用户表中有一些数据

 :012 >   User.all
  User Load (10.3ms)  SELECT  "users".* FROM "users" LIMIT $1  [["LIMIT", 11]]
 => #<ActiveRecord::Relation [#<User id: 1, email: "test@gmai.com", first_name: "test", last_name: "test", parent_id: nil, created_at: "2019-06-17 05:50:15", updated_at: "2019-06-17 09:27:56", role: "pm_lead", is_approved: true, phone: nil, country_code: nil, initials: nil, theme_code: "#4fa399", profile_pic: nil, is_guest: false, guest_migrated: false, projects_count: 0, is_archived: false, office: nil, department: nil, designation: nil, partner_id: 1>]> 

Elasticsearch 错误:

Elasticsearch::Transport::Transport::Errors::BadRequest: [400] {"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"Root mapping definition has unsupported parameters:  [user : {_routing={}, dynamic_templates=[{string_template={mapping={ignore_above=30000, type=keyword, fields={analyzed={analyzer=searchkick_index, index=true, type=text}}}, match_mapping_type=string, match=*}}], properties={name={ignore_above=30000, type=keyword, fields={analyzed={analyzer=searchkick_index, index=true, type=text}, text_middle={analyzer=searchkick_text_middle_index, index=true, type=text}}}, last_name={ignore_above=30000, type=keyword, fields={analyzed={analyzer=searchkick_index, index=true, type=text}, text_middle={analyzer=searchkick_text_middle_index, index=true, type=text}}}, first_name={ignore_above=30000, type=keyword, fields={analyzed={analyzer=searchkick_index, index=true, type=text}, text_middle={analyzer=searchkick_text_middle_index, index=true, type=text}}}}}]"}],"type":"mapper_parsing_exception","reason":"Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters:  [user : {_routing={}, dynamic_templates=[{string_template={mapping={ignore_above=30000, type=keyword, fields={analyzed={analyzer=searchkick_index, index=true, type=text}}}, match_mapping_type=string, match=*}}], properties={name={ignore_above=30000, type=keyword, fields={analyzed={analyzer=searchkick_index, index=true, type=text}, text_middle={analyzer=searchkick_text_middle_index, index=true, type=text}}}, last_name={ignore_above=30000, type=keyword, fields={analyzed={analyzer=searchkick_index, index=true, type=text}, text_middle={analyzer=searchkick_text_middle_index, index=true, type=text}}}, first_name={ignore_above=30000, type=keyword, fields={analyzed={analyzer=searchkick_index, index=true, type=text}, text_middle={analyzer=searchkick_text_middle_index, index=true, type=text}}}}}]","caused_by":{"type":"mapper_parsing_exception","reason":"Root mapping definition has unsupported parameters:  [user : {_routing={}, dynamic_templates=[{string_template={mapping={ignore_above=30000, type=keyword, fields={analyzed={analyzer=searchkick_index, index=true, type=text}}}, match_mapping_type=string, match=*}}], properties={name={ignore_above=30000, type=keyword, fields={analyzed={analyzer=searchkick_index, index=true, type=text}, text_middle={analyzer=searchkick_text_middle_index, index=true, type=text}}}, last_name={ignore_above=30000, type=keyword, fields={analyzed={analyzer=searchkick_index, index=true, type=text}, text_middle={analyzer=searchkick_text_middle_index, index=true, type=text}}}, first_name={ignore_above=30000, type=keyword, fields={analyzed={analyzer=searchkick_index, index=true, type=text}, text_middle={analyzer=searchkick_text_middle_index, index=true, type=text}}}}}]"}},"status":400}

最佳答案

我得到了我的问题的解决方案。只需将 searchkick gem 版本从 3.1 版更新到 4.01 版。

-    searchkick (3.1.0)
-      activemodel (>= 4.2)
-      elasticsearch (>= 5)
+    searchkick (4.0.2)
+      activemodel (>= 5)
+      elasticsearch (>= 6)

关于ruby-on-rails - Rails 5.1 与 ElasticSearch 7.1 重建索引错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56734907/

相关文章:

ruby-on-rails - Rails 3.1 限制用户创建的对象

ruby-on-rails - 来自 Controller 的mongoid随机

mysql - 2 个 HTTP 请求同时检查记录是否存在,如果不存在则创建它 = 重复记录

用于对文档进行分类的 Elasticsearch 插件

python - Elasticsearch 查询在 Python 中使用 httplib 给出 "No handler for uri"

ruby-on-rails - 在 Rails 中使用数据库列别名时出现 NoMethodError

mysql - rails 中的多个表连接

ruby-on-rails - byebug 中的 Rails 多行调试或如何在单行中进行救援

ruby-on-rails - 按名称分组但忽略大小写

c# - 您可以将Elasticsearch “q” querystring参数解析为NEST对象吗?