Created
December 3, 2014 15:14
-
-
Save awwaiid/ad7b0eb0ffb2eafa4e39 to your computer and use it in GitHub Desktop.
index a given array of records
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/searchers/elasticsearch/bulk_indexable.rb | |
# This was my sketch of an idea for a way to index a specific given set of records | |
# "records" here is an array of units, which it batches with #each_slice | |
def index_records(records, new_index=nil) | |
Rails.logger.info("[ElasticSearch] Indexing given records") | |
records.each_slice(BULK_OPERATION_LIMIT) do |record_batch| | |
batch_index(record_batch, new_index) | |
end | |
client.indices.optimize index: (new_index || index_name) | |
set_latest_reindex_at end_at | |
offset | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment