Use flushBatch instead of setting batchSize

The code was refactored to use the new general purpose
method flushBatch to add any outstanding batch documents
and flush the index.