redmine_elasticsearch
redmine_elasticsearch copied to clipboard
Elasticsearch 5.6: Document mapping type name can't start with '_'
Attempting to get the plugin running on FreeBSD and the command:
bundle exec rake redmine_elasticsearch:reindex_all RAILS_ENV=production
yields
Loading Rails environment for Resque
Recreating index and updating mapping...
2018-09-26 09:22:32 -0700: HEAD http://127.0.0.1:9200/redmineapp_production [status:200, request:0.049s, query:n/a]
2018-09-26 09:22:32 -0700: <
2018-09-26 09:22:32 -0700: DELETE http://127.0.0.1:9200/redmineapp_production [status:200, request:0.072s, query:n/a]
2018-09-26 09:22:32 -0700: < {"acknowledged":true}
2018-09-26 09:22:32 -0700: PUT http://127.0.0.1:9200/redmineapp_production [status:200, request:0.149s, query:n/a]
2018-09-26 09:22:32 -0700: > {"settings":{"index":{"number_of_shards":1,"number_of_replicas":0},"analysis":{"analyzer":{"default":{"type":"custom","tokenizer":"standard","filter":["lowercase","russian_morphology","english_morphology","main_stopwords"]},"default_search":{"type":"custom","tokenizer":"standard","filter":["lowercase","russian_morphology","english_morphology","main_stopwords"]}},"filter":{"main_stopwords":{"type":"stop","stopwords":["а","без","более","бы","был","была","были","было","быть","в","вам","вас","весь","во","вот","все","всего","всех","вы","где","да","даже","для","до","его","ее","если","есть","еще","же","за","здесь","и","из","или","им","их","к","как","ко","когда","кто","ли","либо","мне","может","мы","на","надо","наш","не","него","нее","нет","ни","них","но","ну","о","об","однако","он","она","они","оно","от","очень","по","под","при","с","со","так","также","такой","там","те","тем","то","того","тоже","той","только","том","ты","у","уже","хотя","чего","чей","чем","что","чтобы","чье","чья","эта","эти","это","я","a","an","and","are","as","at","be","but","by","for","if","in","into","is","it","no","not","of","on","or","such","that","the","their","then","there","these","they","this","to","was","will","with"]},"main_ngrams":{"type":"edgeNGram","min_gram":1,"max_gram":20}}}},"mappings":{"_default_":{"properties":{"type":{"type":"keyword"},"title":{"type":"text"},"description":{"type":"text"},"datetime":{"type":"date"},"url":{"type":"text","index":"not_analyzed"}}}}}
2018-09-26 09:22:32 -0700: < {"acknowledged":true,"shards_acknowledged":true,"index":"redmineapp_production"}
2018-09-26 09:22:32 -0700: PUT http://127.0.0.1:9200/redmineapp_production/_mapping/_doc [status:400, request:0.424s, query:N/A]
2018-09-26 09:22:32 -0700: > {"_doc":{"_parent":{"type":"parent_project"}}}
2018-09-26 09:22:32 -0700: < {"error":{"root_cause":[{"type":"invalid_type_name_exception","reason":"Document mapping type name can't start with '_', found: [_doc]"}],"type":"invalid_type_name_exception","reason":"Document mapping type name can't start with '_', found: [_doc]"},"status":400}
2018-09-26 09:22:32 -0700: [400] {"error":{"root_cause":[{"type":"invalid_type_name_exception","reason":"Document mapping type name can't start with '_', found: [_doc]"}],"type":"invalid_type_name_exception","reason":"Document mapping type name can't start with '_', found: [_doc]"},"status":400}
rake aborted!
searching for the error indicates the previously default mapping of "_doc" is now not allowed (but corrected in 6.4+) This should be as easy as replacing "_doc" with "doc" but I'm not sure where to do so.
I ran into this as well and figured out part of it.
_doc is the default document type for the elasticsearch-model gem. You can override the default where Elasticsearch::Model gets included plugins/redmine_elasticsearch/app/elastic/application_search.rb. Change:
include Elasticsearch::Model
to:
include Elasticsearch::Model
document_type 'doc'
You also need to add it in plugins/redmine_elasticsearch/app/models/parent_project.rb
class ParentProject < Project
index_name RedmineElasticsearch::INDEX_NAME
class ParentProject < Project
index_name RedmineElasticsearch::INDEX_NAME
document_type "doc"
Now the rake task runs, but the indexes don't build with an error of:
"index"=>
{"_index"=>"redmineapp_development",
"_type"=>"doc",
"_id"=>"1",
"status"=>400,
"error"=>
{"type"=>"routing_missing_exception",
"reason"=>"routing is required for [redmineapp_development]/[doc]/[1]",
"index_uuid"=>"_na_",
"index"=>"redmineapp_development"}}}
@spikex - this looks good but I have to admit weakness: I switched to DMSF/xapian. That works well and indexes file contents. I found some of the translators had problematic dependencies for FreeBSD and omitted those, a few of the others I think aren't actually tied in to the FreeBSD config (Linux->FreeBSD adds /local/ into the path for a lot of binaries).
@gessel, @spikex You should specify "elasticsearch-model" gem version: gem 'elasticsearch-model', git: "https://github.com/elastic/elasticsearch-rails.git", branch: "5.x"