app/jobs/solidus/elastic_product/reindex_job.rb
# Moves the alias to the new index, or
# creates one if an alias doesn't exist yet
#
# borrowed from searchkick/lib/searchkick/index.rb:190
Moves the alias to the new index, or
creates one if an alias doesn't exist yet


Moves the alias to the new index or creates one if an alias doesn ' t exist yet
def swap(new_name)
      actions = []
      if client.indices.exists_alias(name: index_name)
        old_index_names = client.indices.get_alias(name: index_name).keys
        actions += old_index_names.map do |old_name|
          { remove: { index: old_name, alias: index_name } }
        end
      end
      actions += [{ add: { index: new_name, alias: index_name } }]
      client.indices.update_aliases body: { actions: actions }
    end
def swap ( new_name ) actions = [ ] if client . indices . exists_alias ( name : index_name ) old_index_names = client . indices . get_alias ( name : index_name ) . keys actions += old_index_names . map do | old_name | { remove : { index : old_name , alias : index_name } } end end actions += [ { add : { index : new_name , alias : index_name } } ] client . indices . update_aliases body : { actions : actions } end
Moves the alias to the new index, or
creates one if an alias doesn't exist yet
Moves the alias to the new index or creates one if an alias doesn ' t exist yet
new_name