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

Returns a new instance of ScanCursor.



150
151
152
153
154
155
156
# File 'lib/elasticity/search.rb', line 150

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

Returns:

  • (Boolean)


162
163
164
# File 'lib/elasticity/search.rb', line 162

def blank?
  empty?
end

#eachObject



176
177
178
179
180
# File 'lib/elasticity/search.rb', line 176

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

#each_batchObject



170
171
172
173
174
# File 'lib/elasticity/search.rb', line 170

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

#empty?Boolean

Returns:

  • (Boolean)


158
159
160
# File 'lib/elasticity/search.rb', line 158

def empty?
  total == 0
end

#totalObject



166
167
168
# File 'lib/elasticity/search.rb', line 166

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