def recreate_indexes(es=None, indexes=None):
    if es is None:
        es = get_es()
    if indexes is None:
        indexes = all_write_indexes()

    for index in indexes:
        delete_index(index)

        # There should be no mapping-conflict race here since the index doesn't
        # exist. Live indexing should just fail.

        # Simultaneously create the index, the mappings, the analyzers, and
        # the tokenizers, so live indexing doesn't get a chance to index
        # anything between and infer a bogus mapping (which ES then freaks
        # out over when we try to lay in an incompatible explicit mapping).
        es.indices.create(index=index, body={
            'mappings': get_mappings(index),
            'settings': {
                'analysis': get_analysis(),
            }
        })

    # Wait until the index is there.
    es.cluster.health(wait_for_status='yellow')
Deletes indexes and recreates them.
dataset/ETHPy150Open mozilla/kitsune/kitsune/search/es_utils.py/recreate_indexes