@task
def post_index(new_index, old_index, alias, index_name, settings):
 _print('Optimizing, updating settings and aliases.', alias)
 ES.indices.optimize(index=new_index)
 ES.indices.put_settings(index=new_index, body=settings)
 actions = [{'add': {'index': new_index, 'alias': alias}}]
 if old_index:
  actions.append({'remove': {'index': old_index, 'alias': alias}})
 ES.indices.update_aliases(body=dict(actions=actions))
 _print('Unflagging the database.', alias)
 Reindexing.unflag_reindexing(alias=alias)
 _print('Removing index {index}.'.format(index=old_index), alias)
 if (old_index and ES.indices.exists(index=old_index)):
  ES.indices.delete(index=old_index)
 alias_output = ''
 for indexer in INDEXERS:
  alias = ES_INDEXES[indexer.get_mapping_type_name()]
  alias_output += (unicode(ES.indices.get_aliases(index=alias)) + '\n')
 _print('Reindexation done. Current aliases configuration: {output}\n'.format(output=alias_output), alias)

@ task def post_index ( new_index , old_index , alias , index_name , settings ) : _print ( 'Optimizing, updating settings and aliases.' , alias ) ES . indices . optimize ( index = new_index ) ES . indices . put_settings ( index = new_index , body = settings ) actions = [ { 'add' : { 'index' : new_index , 'alias' : alias } } ] if old_index : actions . append ( { 'remove' : { 'index' : old_index , 'alias' : alias } } ) ES . indices . update_aliases ( body = dict ( actions = actions ) ) _print ( 'Unflagging the database.' , alias ) Reindexing . unflag_reindexing ( alias = alias ) _print ( 'Removing index {index}.' . format ( index = old_index ) , alias ) if ( old_index and ES . indices . exists ( index = old_index ) ) : ES . indices . delete ( index = old_index ) alias_output = '' for indexer in INDEXERS : alias = ES_INDEXES [ indexer . get_mapping_type_name ( ) ] alias_output += ( unicode ( ES . indices . get_aliases ( index = alias ) ) + '\n' ) _print ( 'Reindexation done. Current aliases configuration: {output}\n' . format ( output = alias_output ) , alias )
perform post-indexing tasks: * optimize .