Module: Elasticsearch::Persistence::FinderMethods

Included in:
Relation
Defined in:
lib/elasticsearch/persistence/relation/finder_methods.rb

Instance Method Summary collapse

Instance Method Details

#countObject



26
27
28
29
# File 'lib/elasticsearch/persistence/relation/finder_methods.rb', line 26

def count
  return results.count if @loaded
  spawn.count!
end

#count!Object



31
32
33
34
35
# File 'lib/elasticsearch/persistence/relation/finder_methods.rb', line 31

def count!
  @values[:count] = true
  @values.delete(:size)
  spawn.to_a["count"]
end

#firstObject



6
7
8
9
# File 'lib/elasticsearch/persistence/relation/finder_methods.rb', line 6

def first
  return results.first if @loaded
  spawn.first!.results.first
end

#first!Object



11
12
13
14
# File 'lib/elasticsearch/persistence/relation/finder_methods.rb', line 11

def first!
  spawn.sort(Hash[default_sort_key, :asc]).spawn.size(1)
  self
end

#lastObject



16
17
18
19
# File 'lib/elasticsearch/persistence/relation/finder_methods.rb', line 16

def last
  return results.last if @loaded
  spawn.last!.results.first
end

#last!Object



21
22
23
24
# File 'lib/elasticsearch/persistence/relation/finder_methods.rb', line 21

def last!
  spawn.sort(Hash[default_sort_key, :desc]).spawn.size(1)
  self
end