module Elasticsearch::Persistence::FinderMethods

Public Instance Methods

count() click to toggle source
# File lib/elasticsearch/persistence/relation/finder_methods.rb, line 26
def count
  return results.count if @loaded
  spawn.count!
end
count!() click to toggle source
# File lib/elasticsearch/persistence/relation/finder_methods.rb, line 31
def count!
  @values[:count] = true
  @values.delete(:size)
  spawn.to_a["count"]
end
first() click to toggle source
# File lib/elasticsearch/persistence/relation/finder_methods.rb, line 6
def first
  return results.first if @loaded
  spawn.first!.results.first
end
first!() click to toggle source
# File lib/elasticsearch/persistence/relation/finder_methods.rb, line 11
def first!
  spawn.sort(Hash[default_sort_key, :asc]).spawn.size(1)
  self
end
last() click to toggle source
# File lib/elasticsearch/persistence/relation/finder_methods.rb, line 16
def last
  return results.last if @loaded
  spawn.last!.results.first
end
last!() click to toggle source
# File lib/elasticsearch/persistence/relation/finder_methods.rb, line 21
def last!
  spawn.sort(Hash[default_sort_key, :desc]).spawn.size(1)
  self
end