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, mapper, size: 100, scroll: "1m") ⇒ ScanCursor

Returns a new instance of ScanCursor.



162
163
164
165
166
167
168
# File 'lib/elasticity/search.rb', line 162

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

Instance Method Details

#blank?Boolean

Returns:

  • (Boolean)


174
175
176
# File 'lib/elasticity/search.rb', line 174

def blank?
  empty?
end

#eachObject



188
189
190
191
192
# File 'lib/elasticity/search.rb', line 188

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

#each_batchObject



182
183
184
185
186
# File 'lib/elasticity/search.rb', line 182

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

#empty?Boolean

Returns:

  • (Boolean)


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

def empty?
  total == 0
end

#totalObject



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

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