Method: Whistlepig::Index#each_result_for

Defined in:
lib/whistlepig.rb

#each_result_for(query, chunk_size = 10) ⇒ Object

Runs a query and yield each matching doc id. Handles the mechanics of setting up and tearing down the query.



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/whistlepig.rb', line 21

def each_result_for query, chunk_size=10
  setup_query query
  begin
    while true
      results = run_query query, chunk_size
      results.each { |r| yield r }
      break if results.size < chunk_size
    end
  ensure
    teardown_query query
  end
  self
end