Class: Elasticity::Search::ScanCursor

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/elasticity/search.rb

Instance Method Summary collapse

Constructor Details

#initialize(client, search_definition, document_klass, size: 100, scroll: "1m") ⇒ ScanCursor


121
122
123
124
125
126
127
# File 'lib/elasticity/search.rb', line 121

def initialize(client, search_definition, document_klass, size: 100, scroll: "1m")
  @client            = client
  @search_definition = search_definition
  @document_klass    = document_klass
  @size              = size
  @scroll            = scroll
end

Instance Method Details

#blank?Boolean


133
134
135
# File 'lib/elasticity/search.rb', line 133

def blank?
  empty?
end

#eachObject


147
148
149
150
151
# File 'lib/elasticity/search.rb', line 147

def each
  enumerator.each do |group|
    group.each { |doc| yield(doc) }
  end
end

#each_batchObject


141
142
143
144
145
# File 'lib/elasticity/search.rb', line 141

def each_batch
  enumerator.each do |group|
    yield(group)
  end
end

#empty?Boolean


129
130
131
# File 'lib/elasticity/search.rb', line 129

def empty?
  total == 0
end

#totalObject


137
138
139
# File 'lib/elasticity/search.rb', line 137

def total
  search["hits"]["total"]
end