in utils/es.py [0:0]
def create_index(client: Elasticsearch, index_name: str, mappings: {} = {}, settings: {} = {}):
"""
Create new ES index. If the index already exists, it will be deleted and a new one created.
:param client: ES client.
:param index_name: name of the index.
:param mappings: mappings to be used for the new index. If not specified, default ones will be used.
:param settings: settings to be used for the new index. If not specified, default ones will be used.
"""
if client.indices.exists(index=index_name):
client.indices.delete(index=index_name)
client.indices.create(index=index_name, mappings=mappings, settings=settings)
print("Index {name} successfully created.\n".format(name=index_name))