Class: Elasticsearch::Model::Response::Response

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/elasticsearch/model/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

Instance Method Summary collapse

Constructor Details

#initialize(klass, search, options = {}) ⇒ Response

Returns a new instance of Response.



20
21
22
23
# File 'lib/elasticsearch/model/response.rb', line 20

def initialize(klass, search, options={})
  @klass     = klass
  @search    = search
end

Instance Attribute Details

#klassObject (readonly)

Returns the value of attribute klass.



13
14
15
# File 'lib/elasticsearch/model/response.rb', line 13

def klass
  @klass
end

#responseHash (readonly)

Returns the Elasticsearch response

Returns:

  • (Hash)


29
30
31
# File 'lib/elasticsearch/model/response.rb', line 29

def response
  @response
end

#searchObject (readonly)

Returns the value of attribute search.



13
14
15
# File 'lib/elasticsearch/model/response.rb', line 13

def search
  @search
end

#shardsObject (readonly)

Returns the statistics on shards



65
66
67
# File 'lib/elasticsearch/model/response.rb', line 65

def shards
  @shards
end

#timed_outObject (readonly)

Returns whether the response timed out



59
60
61
# File 'lib/elasticsearch/model/response.rb', line 59

def timed_out
  @timed_out
end

#tookObject (readonly)

Returns the “took” time



53
54
55
# File 'lib/elasticsearch/model/response.rb', line 53

def took
  @took
end

Instance Method Details

#recordsRecords

Returns the collection of records from the database

Returns:



47
48
49
# File 'lib/elasticsearch/model/response.rb', line 47

def records
  @records ||= Records.new(klass, self)
end

#resultsResults

Returns the collection of “hits” from Elasticsearch

Returns:



39
40
41
# File 'lib/elasticsearch/model/response.rb', line 39

def results
  @results ||= Results.new(klass, self)
end