简体   繁体   中英

Rails 5.1 with ElasticSearch 7.1 reindex error

I am facing some issue while run this command on Rails 5 console .

:017 > User.reindex

I have some data in users table

 :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 error:

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}

I got the solution of my problem. Just update the searchkick gem version version 3.1 to 4.01.

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

gem 'searchkick', '~> 4.01' works with elasticseatch 7.x

gem 'searchkick', '~> 3.1', '>= 3.1.2' this works with elasticseatch 6.x

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM