Ahm*_*Ali 4 ruby-on-rails elasticsearch elasticsearch-model elasticsearch-rails
我在使用elasticsearch-rails时遇到问题,当我使用时Business.__elasticsearch__.create_index!出现错误:
{“error”:{“root_cause”:[{“type”:“mapper_parsing_exception”,“reason”:“根映射定义具有不受支持的参数:[业务:{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":"根映射定义具有不受支持的参数:[业务:{dynamic=true,properties={id={type=integer }}}]“}},”状态“:400}
该请求的背后是:
PUT http://localhost:9200/development_businesses [状态:400,请求:0.081s,查询:N/A] {"settings":{"index":{"number_of_shards":1}},"mappings":{ "business":{"dynamic":"true","properties":{"id":{"type":"integer"}}}}}
我的模型代码:
`
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
`
Run Code Online (Sandbox Code Playgroud)
我已经定义了我的映射:
`
settings index: { number_of_shards: 1 } do
mappings dynamic: 'true' do
indexes :id, type: 'integer'
end
end
`
Run Code Online (Sandbox Code Playgroud)
{"business":{"dynamic":"true"创建映射时删除 }} 部分。尝试像下面这样对我来说效果很好-
PUT /development_businesses/
{
"settings": {
"index": {
"number_of_shards": 1
}
},
"mappings": {
"properties": {
"id": {
"type": "integer"
}
}
}
}
Run Code Online (Sandbox Code Playgroud)