Rails __elasticsearch __。create_index!“根映射定义具有不受支持的参数(mapper_parsing_exception)”

艾哈迈德·阿里

我在使用Elasticsearch-rails遇到问题,使用时Business.__elasticsearch__.create_index!遇到错误:

{“错误”:{“ root_cause”:[{“类型”:“ mapper_parsing_exception”,“原因”:“根映射定义具有不受支持的参数:[业务:{dynamic = true,properties = {id = {type = integer} }}]“}],” type“:” mapper_parsing_exception“,”原因“:”无法解析映射[_doc]:根映射定义具有不受支持的参数:[业务:{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,查询:不适用] {“设置”:{“索引”:{“编号碎片”:1}},“映射”:{ “ 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"
        }
      }
  }
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章