gpt4 book ai didi

ruby-on-rails - Rails __elasticsearch__.create_index! "Root mapping definition has unsupported parameters(mapper_parsing_exception)"

转载 作者:行者123 更新时间:2023-12-02 22:12:01 27 4
gpt4 key购买 nike

当我使用 Business.__elasticsearch__.create_index! 时,elasticsearch-rails 出现问题我收到一个错误:

{"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"Root mapping definition has unsupported parameters: [business : {dynamic=true, properties={id={type=integer}}}]"}],"type":"mapper_parsing_exception","reason":"Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters: [business : {dynamic=true, properties={id={type=integer}}}]","caused_by":{"type":"mapper_parsing_exception","reason":"Root mapping definition has unsupported parameters: [business : {dynamic=true, properties={id={type=integer}}}]"}},"status":400}

该请求的背后是:

PUT http://localhost:9200/development_businesses [status:400, request:0.081s, query: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
`

我已经定义了我的映射:

`
settings index: { number_of_shards: 1 } do
mappings dynamic: 'true' do
indexes :id, type: 'integer'
end
end
`

最佳答案

在创建映射时删除部分 {"business":{"dynamic":"true"}}。像下面那样尝试对我来说效果很好-

PUT /development_businesses/
{
"settings": {
"index": {
"number_of_shards": 1
}
},
"mappings": {
"properties": {
"id": {
"type": "integer"
}
}
}
}

关于ruby-on-rails - Rails __elasticsearch__.create_index! "Root mapping definition has unsupported parameters(mapper_parsing_exception)",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59141034/

27 4 0