@task
def finalize_index(index_pk):
 from kuma.wiki.search import WikiDocumentType
 from kuma.search.models import Index
 cls = WikiDocumentType
 es = cls.get_connection('indexing')
 index = Index.objects.get(pk=index_pk)
 es.indices.optimize(index=index.prefixed_name)
 index_settings = {'index': {'refresh_interval': settings.ES_DEFAULT_REFRESH_INTERVAL, 'number_of_replicas': settings.ES_DEFAULT_NUM_REPLICAS}}
 es.indices.put_settings(index=index.prefixed_name, body=index_settings)
 index.populated = True
 index.save()
 subject = ('Index %s completely populated' % index.prefixed_name)
 message = 'You may want to promote it now via the admin interface.'
 mail_admins(subject=subject, message=message)

@ task def finalize_index ( index_pk ) : from kuma . wiki . search import WikiDocumentType from kuma . search . models import Index cls = WikiDocumentType es = cls . get_connection ( 'indexing' ) index = Index . objects . get ( pk = index_pk ) es . indices . optimize ( index = index . prefixed_name ) index_settings = { 'index' : { 'refresh_interval' : settings . ES_DEFAULT_REFRESH_INTERVAL , 'number_of_replicas' : settings . ES_DEFAULT_NUM_REPLICAS } } es . indices . put_settings ( index = index . prefixed_name , body = index_settings ) index . populated = True index . save ( ) subject = ( 'Index %s completely populated' % index . prefixed_name ) message = 'You may want to promote it now via the admin interface.' mail_admins ( subject = subject , message = message )
finalizes the elasticsearch index .