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

时间:2017-08-02 15:28:28

标签: ruby-on-rails ruby elasticsearch-model

我正在使用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={}>

如何通过此搜索方法访问我的记录?

1 个答案:

答案 0 :(得分:0)

您应该习惯

  

回复

records

例如示例

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

它将返回您的活动记录对象。