Class: Elasticsearch::Rails2::Response::Response

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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, options={})
  @klass     = klass
  @search    = search
end

Instance Attribute Details

#klassObject (readonly)

Returns the value of attribute klass.



12
13
14
# File 'lib/elasticsearch/rails2/response.rb', line 12

def klass
  @klass
end

#responseHash (readonly)

Returns the Elasticsearch response

Returns:

  • (Hash)


28
29
30
# File 'lib/elasticsearch/rails2/response.rb', line 28

def response
  @response
end

#searchObject (readonly)

Returns the value of attribute search.



12
13
14
# File 'lib/elasticsearch/rails2/response.rb', line 12

def search
  @search
end

#shardsObject (readonly)

Returns the statistics on shards



64
65
66
# File 'lib/elasticsearch/rails2/response.rb', line 64

def shards
  @shards
end

#timed_outObject (readonly)

Returns whether the response timed out



58
59
60
# File 'lib/elasticsearch/rails2/response.rb', line 58

def timed_out
  @timed_out
end

#tookObject (readonly)

Returns the “took” time



52
53
54
# File 'lib/elasticsearch/rails2/response.rb', line 52

def took
  @took
end

Instance Method Details

#recordsRecords

Returns the collection of records from the database

Returns:

  • (Records)


46
47
48
# File 'lib/elasticsearch/rails2/response.rb', line 46

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

#resultsResults

Returns the collection of “hits” from Elasticsearch

Returns:



38
39
40
# File 'lib/elasticsearch/rails2/response.rb', line 38

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

#scroll_idObject

Returns whether the response scroll id



70
71
72
# File 'lib/elasticsearch/rails2/response.rb', line 70

def scroll_id
  response['_scroll_id']
end