我在使用elasticsearch-rails时遇到问题,使用时Business.__elasticsearch__.create_index!
出现错误:
{"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"根映射定义有不受支持的参数:[business : {dynamic=true, properties={id={type=integer} }}]"}],"type":"mapper_parsing_exception","reason":"无法解析映射 [_doc]:根映射定义有不受支持的参数:[business : {dynamic=true, properties={id={type =integer}}}]","caused_by":{"type":"mapper_parsing_exception","reason":"根映射定义有不受支持的参数:[business : {dynamic=true, properties={id={type=integer }}}]"}},"状态":400}
该请求的背后是:
PUT http://localhost:9200/development_businesses [status:400, request:0.081s, query:N/A] {"settings":{"index":{"number_of_shards":1}},"mappings":{ “业务”:{“动态”:“真”,“属性”:{“id”:{“类型”:“整数”}}}}}
我的型号代码:
`
after_save :reindex_model
Elasticsearch::Model.client = Elasticsearch::Client.new url: ENV['BONSAI_URL'], log: true
include Elasticsearch::Model
include Elasticsearch::Model::Callbacks
index_name [Rails.env, model_name.collection.gsub('///', '-')].join('_')
document_type self.name.downcase
`
我已经定义了我的映射:
`
settings index: { number_of_shards: 1 } do
mappings dynamic: 'true' do
indexes :id, type: 'integer'
end
end
`