@task
def pre_index(new_index, old_index, alias, index_name, settings):
 indexer = INDEXER_MAP[index_name]
 _print('Flagging the database to start the reindexation.', alias)
 Reindexing.flag_reindexing(new_index=new_index, old_index=old_index, alias=alias)
 time.sleep(5)
 _print('Creating the mapping for index {index}.'.format(index=new_index), alias)
 settings = {'settings': settings, 'mappings': indexer.get_mapping()}
 try:
  ES.indices.create(index=new_index, body=settings)
 except elasticsearch.ElasticsearchException as e:
  raise CommandError(('ERROR: New index [%s] already exists? %s' % (new_index, e)))
 ES.cluster.health(index=new_index, wait_for_status='green', wait_for_relocating_shards=0)

@ task def pre_index ( new_index , old_index , alias , index_name , settings ) : indexer = INDEXER_MAP [ index_name ] _print ( 'Flagging the database to start the reindexation.' , alias ) Reindexing . flag_reindexing ( new_index = new_index , old_index = old_index , alias = alias ) time . sleep ( 5 ) _print ( 'Creating the mapping for index {index}.' . format ( index = new_index ) , alias ) settings = { 'settings' : settings , 'mappings' : indexer . get_mapping ( ) } try : ES . indices . create ( index = new_index , body = settings ) except elasticsearch . ElasticsearchException as e : raise CommandError ( ( 'ERROR: New index [%s] already exists? %s' % ( new_index , e ) ) ) ES . cluster . health ( index = new_index , wait_for_status = 'green' , wait_for_relocating_shards = 0 )
this sets up everything needed before indexing: * flags the database .