Class: Elasticsearch::Rails2::Response::Response
- Inherits:
-
Object
- Object
- Elasticsearch::Rails2::Response::Response
- Includes:
- Enumerable
- Defined in:
- lib/elasticsearch/rails2/response.rb
Overview
Encapsulate the response returned from the Elasticsearch client
Implements Enumerable and forwards its methods to the #results object.
Instance Attribute Summary collapse
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
-
#response ⇒ Hash
readonly
Returns the Elasticsearch response.
-
#search ⇒ Object
readonly
Returns the value of attribute search.
-
#shards ⇒ Object
readonly
Returns the statistics on shards.
-
#timed_out ⇒ Object
readonly
Returns whether the response timed out.
-
#took ⇒ Object
readonly
Returns the “took” time.
Instance Method Summary collapse
-
#initialize(klass, search, options = {}) ⇒ Response
constructor
A new instance of Response.
-
#records ⇒ Records
Returns the collection of records from the database.
-
#results ⇒ Results
Returns the collection of “hits” from Elasticsearch.
-
#scroll_id ⇒ Object
Returns whether the response scroll id.
Constructor Details
#initialize(klass, search, options = {}) ⇒ Response
Returns a new instance of Response.
19 20 21 22 |
# File 'lib/elasticsearch/rails2/response.rb', line 19 def initialize(klass, search, ={}) @klass = klass @search = search end |
Instance Attribute Details
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
12 13 14 |
# File 'lib/elasticsearch/rails2/response.rb', line 12 def klass @klass end |
#response ⇒ Hash (readonly)
Returns the Elasticsearch response
28 29 30 |
# File 'lib/elasticsearch/rails2/response.rb', line 28 def response @response end |
#search ⇒ Object (readonly)
Returns the value of attribute search.
12 13 14 |
# File 'lib/elasticsearch/rails2/response.rb', line 12 def search @search end |
#shards ⇒ Object (readonly)
Returns the statistics on shards
64 65 66 |
# File 'lib/elasticsearch/rails2/response.rb', line 64 def shards @shards end |
#timed_out ⇒ Object (readonly)
Returns whether the response timed out
58 59 60 |
# File 'lib/elasticsearch/rails2/response.rb', line 58 def timed_out @timed_out end |
#took ⇒ Object (readonly)
Returns the “took” time
52 53 54 |
# File 'lib/elasticsearch/rails2/response.rb', line 52 def took @took end |
Instance Method Details
#records ⇒ Records
Returns the collection of records from the database
46 47 48 |
# File 'lib/elasticsearch/rails2/response.rb', line 46 def records @records ||= Records.new(klass, self) end |
#results ⇒ Results
Returns the collection of “hits” from Elasticsearch
38 39 40 |
# File 'lib/elasticsearch/rails2/response.rb', line 38 def results @results ||= Results.new(klass, self) end |
#scroll_id ⇒ Object
Returns whether the response scroll id
70 71 72 |
# File 'lib/elasticsearch/rails2/response.rb', line 70 def scroll_id response['_scroll_id'] end |