gpt4 book ai didi

ruby - 使用ElasticSearch ruby​​ gem按名称获取索引

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

我的模特:

class Package < ActiveRecord::Base
include Elasticsearch::Model
include Elasticsearch::Model::Callbacks
end

当我询问索引是否存在时,我得到 true:
Package.__elasticsearch__.client.indices.exists(index: "packages")
=> true

但是当我这样做时:
Package.__elasticsearch__.client.indices.get(index: "packages")

我收到此错误:
Elasticsearch::Transport::Transport::Errors::BadRequest: [400] No handler found for uri [/packages] and method [GET]

我已经为一些文档建立了索引,并且可以进行搜索,所以上面的行有什么问题?

ps:这是文件: http://www.rubydoc.info/gems/elasticsearch-api/Elasticsearch/API/Indices/Actions

最佳答案

这可能是您在初始化程序中配置Elasticsearch客户端的方式。如果您使用的是typhoeus适配器,请参见以下讨论:https://github.com/elasticsearch/elasticsearch-rails/issues/316

可能还有用的是调试如何通过其惊奇的插件http://localhost:9200/_plugin/marvel/sense/index.html对事物进行实际索引/映射?

GET _cat / indices
GET包/映射

关于ruby - 使用ElasticSearch ruby​​ gem按名称获取索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28181495/

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