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.



159
160
161
162
163
164
165
# File 'lib/elasticity/search.rb', line 159

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)


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

def blank?
  empty?
end

#eachObject



185
186
187
188
189
# File 'lib/elasticity/search.rb', line 185

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

#each_batchObject



179
180
181
182
183
# File 'lib/elasticity/search.rb', line 179

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

#empty?Boolean

Returns:

  • (Boolean)


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

def empty?
  total == 0
end

#totalObject



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

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