Skip to content

Commit

Permalink
Refactor solution
Browse files Browse the repository at this point in the history
  • Loading branch information
spilth authored and thatbudakguy committed Aug 6, 2024
1 parent 4f7133b commit bd6a122
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions lib/geo_combine/indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,10 @@ def index(docs)
start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)

# Index in batches; set batch size via BATCH_SIZE
batch = []
docs.each do |doc, path|
if batch.size < @batch_size
batch << [doc, path]
else
total_indexed += index_batch(batch)
batch = [[doc, path]]
end
docs.each_slice(@batch_size) do |slice|
batch = slice.map { |doc, path| [doc, path] }
total_indexed += index_batch(batch)
end
total_indexed += index_batch(batch) unless batch.empty?

# Issue a commit to make sure all documents are indexed
@solr.commit
Expand Down

0 comments on commit bd6a122

Please sign in to comment.