【发布时间】:2018-10-26 00:40:57
【问题描述】:
我的问题是关于使用 elasticsearch ruby 客户端 chewy 更改弹性搜索索引中的字段类型。
我正在尝试更新索引中的字段类型。我收到此错误:illegal_argument_exception。
我读到不可能更改现有索引中的类型,所以我正在考虑重新索引所有内容:rake chewy:reset。我已经尝试了很多事情......我无法让我的重新索引工作。
详细错误:
Elasticsearch::Transport::Transport::Errors::BadRequest: [400] {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"mapper [enabled] cannot be changed from type [text] to [boolean]"}],"type":"illegal_argument_exception","reason":"mapper [enabled] cannot be changed from type [text] to [boolean]"},"status":400}
我以前的索引(默认情况下启用的字段是文本):
class SearchIndex < Chewy::Index
define_type Company, delete_if: :deleted_at do
...
field :enabled
...
end
end
我想要的索引:
class SearchIndex < Chewy::Index
define_type Company, delete_if: :deleted_at do
...
field :enabled, type: 'boolean'
...
end
end
如何使用 Chewy(如果可能,无需通过 curl 请求 ElasticSearch)来使用新字段类型重新索引我的索引?
谢谢。
【问题讨论】:
标签: ruby elasticsearch chewy-gem