gpt4 book ai didi

ruby - 如何使用Chewy更新Elasticsearch字段类型

转载 作者:行者123 更新时间:2023-12-02 23:17:28 24 4
gpt4 key购买 nike

我的问题是关于使用elasticsearch ruby​​客户端chewy更改我的Elasticsearch索引中的字段类型。

我正在尝试更新索引中的字段类型。我收到此错误: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}

我之前的索引(默认情况下,启用字段为texte):
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)来使索引使用新的字段类型重新索引?

谢谢。

最佳答案

我以前没有使用过Chewy,但是查看文档,您应该只能够在ruby控制台中调用SearchIndex.reset!。当然可以删除和重新创建索引,并且应该使用新的数据类型从头开始重新创建索引。

关于ruby - 如何使用Chewy更新Elasticsearch字段类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52968696/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com