Reputation: 1170
I'm using elasticsearch-model and I used concern approach and here is my search method.I have tried my query by curl it returns me back 5 entries but when I used this method
def search_index(*args)
self.__elasticsearch__.search(*args)
end
it's returns me a class
(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={}>
how can I have access to my records by this search method ?
Upvotes: 4
Views: 940
Reputation: 822
You should use to your
respond
records
Like Example
Foo.new().search('1234').response.records
It will return your Active record objects.
Upvotes: 1