gpt4 book ai didi

ruby-on-rails - 通过 elasticsearch-model 搜索不返回记录

转载 作者:行者123 更新时间:2023-12-02 17:52:49 25 4
gpt4 key购买 nike

我正在使用elasticsearch-model,我使用了关注方法,这是我的搜索方法。我已经通过curl尝试了我的查询,它返回了5个条目,但是当我使用此方法时

def search_index(*args)
self.__elasticsearch__.search(*args)
end

它返回给我一个类

(byebug) Entry.search_index('test').records
#<Elasticsearch::Model::Response::Records:0x007f8eb85ca280 @klass=[PROXY] Entry(id: integer, created_at: datetime, updated_at: datetime, source_id: integer, data: text, uuid: string, source_entry_id: string, bytesize: integer), @response=#<Elasticsearch::Model::Response::Response:0x007f8eb85ca370 @klass=[PROXY] Entry(id: integer, created_at: datetime, updated_at: datetime, source_id: integer, data: text, uuid: string, source_entry_id: string, bytesize: integer), @search=#<Elasticsearch::Model::Searching::SearchRequest:0x007f8eb85ca438 @klass=[PROXY] Entry(id: integer, created_at: datetime, updated_at: datetime, source_id: integer, data: text, uuid: string, source_entry_id: string, bytesize: integer), @options={}, @definition={:index=>"self_driving_entries", :type=>"entry", :q=>"test"}>, @records=#<Elasticsearch::Model::Response::Records:0x007f8eb85ca280 ...>>, @options={}>

我怎样才能通过这种搜索方法访问我的记录?

最佳答案

你应该使用你的

respond

records

像示例

Foo.new().search('1234').response.records

它将返回您的 Active record 对象。

关于ruby-on-rails - 通过 elasticsearch-model 搜索不返回记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45465025/

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