original_docstring: Task to rebuild ES index without downtime.
docstring: Task to rebuild ES index without downtime.
docstring_tokens: Task to rebuild ES index without downtime .
code: def index_all_profiles():
      """Task to rebuild ES index without downtime."""
  
      ES_CONN_DEFAULT = 'default'
      ES_CONN_TMP = 'tmp'
      ES_CONN_CURR = 'current'
      ES_INDEX_DEFAULT = connections[ES_CONN_DEFAULT].options['INDEX_NAME']
      ES_INDEX_TMP = connections[ES_CONN_TMP].options['INDEX_NAME']
      ES_INDEX_CURR = connections[ES_CONN_CURR].options['INDEX_NAME']
  
      rebuild_options = {
          'using': [ES_CONN_TMP],
          'workers': settings.ES_REINDEX_WORKERS_NUM,
          'batchsize': settings.ES_REINDEX_BATCHSIZE,
          'interactive': False,
      }
  
      # Rebuild index in ES_INDEX_TMP
      call_command('rebuild_index', **rebuild_options)
  
      # Get `default` ES connection
      es_conn = connections[ES_CONN_DEFAULT].get_backend().conn
  
      # Link `default` index to tmp
      update_aliases_query = {
          "actions": [
              {
                  "remove": {
                      "index": ES_INDEX_CURR,
                      "alias": ES_INDEX_DEFAULT
                  },
                  "add": {
                      "index": ES_INDEX_TMP,
                      "alias": ES_INDEX_DEFAULT
                  },
              }
          ]
      }
  
      es_conn.indices.update_aliases(
          update_aliases_query
      )
  
      rebuild_options['using'] = [ES_CONN_CURR]
  
      # Rebuild index in ES_INDEX_TMP
      call_command('rebuild_index', **rebuild_options)
  
      # Link `default` index to current
      update_aliases_query = {
          "actions": [
              {
                  "add": {
                      "index": ES_INDEX_CURR,
                      "alias": ES_INDEX_DEFAULT
                  },
                  "remove": {
                      "index": ES_INDEX_TMP,
                      "alias": ES_INDEX_DEFAULT
                  },
              }
          ]
      }
  
      es_conn.indices.update_aliases(
          update_aliases_query
      )
  
      # Cleanup `tmp` index
      options = {
          'using': [ES_CONN_TMP],
          'interactive': False
      }
      call_command('clear_index', **options)
code_tokens: def index_all_profiles ( ) : ES_CONN_DEFAULT = 'default' ES_CONN_TMP = 'tmp' ES_CONN_CURR = 'current' ES_INDEX_DEFAULT = connections [ ES_CONN_DEFAULT ] . options [ 'INDEX_NAME' ] ES_INDEX_TMP = connections [ ES_CONN_TMP ] . options [ 'INDEX_NAME' ] ES_INDEX_CURR = connections [ ES_CONN_CURR ] . options [ 'INDEX_NAME' ] rebuild_options = { 'using' : [ ES_CONN_TMP ] , 'workers' : settings . ES_REINDEX_WORKERS_NUM , 'batchsize' : settings . ES_REINDEX_BATCHSIZE , 'interactive' : False , } call_command ( 'rebuild_index' , ** rebuild_options ) es_conn = connections [ ES_CONN_DEFAULT ] . get_backend ( ) . conn update_aliases_query = { "actions" : [ { "remove" : { "index" : ES_INDEX_CURR , "alias" : ES_INDEX_DEFAULT } , "add" : { "index" : ES_INDEX_TMP , "alias" : ES_INDEX_DEFAULT } , } ] } es_conn . indices . update_aliases ( update_aliases_query ) rebuild_options [ 'using' ] = [ ES_CONN_CURR ] call_command ( 'rebuild_index' , ** rebuild_options ) update_aliases_query = { "actions" : [ { "add" : { "index" : ES_INDEX_CURR , "alias" : ES_INDEX_DEFAULT } , "remove" : { "index" : ES_INDEX_TMP , "alias" : ES_INDEX_DEFAULT } , } ] } es_conn . indices . update_aliases ( update_aliases_query ) options = { 'using' : [ ES_CONN_TMP ] , 'interactive' : False } call_command ( 'clear_index' , ** options )
short_docstring: Task to rebuild ES index without downtime.
short_docstring_tokens: Task to rebuild ES index without downtime .
comment: """Task to rebuild ES index without downtime."""$SEP$# Rebuild index in ES_INDEX_TMP$SEP$# Get `default` ES connection$SEP$# Link `default` index to tmp$SEP$# Rebuild index in ES_INDEX_TMP$SEP$# Link `default` index to current$SEP$# Cleanup `tmp` index