@task
def rebuild_search(ctx):
 from website.app import init_app
 import requests
 from website import settings
 init_app(routes=False, set_backends=True)
 if (not settings.ELASTIC_URI.startswith('http')):
  protocol = ('http://' if settings.DEBUG_MODE else 'https://')
 else:
  protocol = ''
 url = '{protocol}{uri}/{index}'.format(protocol=protocol, uri=settings.ELASTIC_URI.rstrip('/'), index=settings.ELASTIC_INDEX)
 print 'Deleting index {}'.format(settings.ELASTIC_INDEX)
 print '----- DELETE {}*'.format(url)
 requests.delete((url + '*'))
 print 'Creating index {}'.format(settings.ELASTIC_INDEX)
 print '----- PUT {}'.format(url)
 requests.put(url)
 migrate_search(ctx)

@ task def rebuild_search ( ctx ) : from website . app import init_app import requests from website import settings init_app ( routes = False , set_backends = True ) if ( not settings . ELASTIC_URI . startswith ( 'http' ) ) : protocol = ( 'http://' if settings . DEBUG_MODE else 'https://' ) else : protocol = '' url = '{protocol}{uri}/{index}' . format ( protocol = protocol , uri = settings . ELASTIC_URI . rstrip ( '/' ) , index = settings . ELASTIC_INDEX ) print 'Deleting index {}' . format ( settings . ELASTIC_INDEX ) print '----- DELETE {}*' . format ( url ) requests . delete ( ( url + '*' ) ) print 'Creating index {}' . format ( settings . ELASTIC_INDEX ) print '----- PUT {}' . format ( url ) requests . put ( url ) migrate_search ( ctx )
delete and recreate the index for elasticsearch .