class Elastics::Result::Search
Attributes
response[R]
Public Class Methods
new(response, options = {})
click to toggle source
# File lib/elastics/result/search.rb, line 6 def initialize(response, options = {}) @response = response @options = options end
Public Instance Methods
aggregations()
click to toggle source
# File lib/elastics/result/search.rb, line 34 def aggregations @aggregations ||= @response['aggregations'.freeze] end
hits()
click to toggle source
# File lib/elastics/result/search.rb, line 11 def hits @hits ||= @response['hits'.freeze] end
ids()
click to toggle source
# File lib/elastics/result/search.rb, line 15 def ids @ids ||= hits['hits'.freeze].map { |x| x['_id'.freeze] } end
ids_to_find()
click to toggle source
Allows to split ids into two parts, if you want to fetch from primary DB less then was found. This method returns the first part, `rest_ids` - the second.
# File lib/elastics/result/search.rb, line 22 def ids_to_find @ids_to_find ||= begin limit = @options[:limit] limit ? ids[0...limit] : ids end end
rest_ids()
click to toggle source
# File lib/elastics/result/search.rb, line 29 def rest_ids limit = @options[:limit] limit ? ids[limit..-1] : [] end
total()
click to toggle source
# File lib/elastics/result/search.rb, line 38 def total hits['total'.freeze] end