Module: Eson::More::Reindex

Defined in:
lib/eson/more/reindex.rb

Instance Method Summary collapse

Instance Method Details

#reindex(from, to) ⇒ Object

Reindex a whole index by scrolling the old one and writing to the new one using a bulk request.

Parameters:

  • from (String)

    the index to reindex from

  • to (String)

    the index to reindex to



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/eson/more/reindex.rb', line 9

def reindex(from, to)
  all(:index => from) do |chunk|
    if chunk.size > 0
      bulk do |b|
        chunk.each do |doc|
          b.index :index => to,
                  :type => doc["_type"],
                  :id => doc["_id"],
                  :doc => doc["_source"]
        end
      end
    end
  end
end