def create_index(self, index_name=uuid4().hex, doc_type='generic_event', mappings=None):
    'Create index with Timesketch settings.\n\n        Args:\n            index_name: Name of the index. Default is a generated UUID.\n            doc_type: Name of the document type. Default id generic_event.\n            mappings: Optional dict with the document mapping for Elastic.\n\n        Returns:\n            Index name in string format.\n            Document type in string format.\n        '
    if mappings:
        _document_mapping = mappings
    else:
        _document_mapping = {'properties': {'timesketch_label': {'type': 'nested'}, 'datetime': {'type': 'date'}}}
    if self.version.startswith('6'):
        _document_mapping = {doc_type: _document_mapping}
    if (not self.client.indices.exists(index_name)):
        try:
            self.client.indices.create(index=index_name, body={'mappings': _document_mapping})
        except ConnectionError as e:
            raise RuntimeError('Unable to connect to Timesketch backend.') from e
        except RequestError:
            index_exists = self.client.indices.exists(index_name)
            es_logger.warning('Attempting to create an index that already exists ({0:s} - {1:s})'.format(index_name, str(index_exists)))
    return (index_name, doc_type)
Create index with Timesketch settings.

Args:
    index_name: Name of the index. Default is a generated UUID.
    doc_type: Name of the document type. Default id generic_event.
    mappings: Optional dict with the document mapping for Elastic.

Returns:
    Index name in string format.
    Document type in string format.
def create_index(self, index_name=uuid4().hex, doc_type='generic_event', mappings=None):
    'Create index with Timesketch settings.\n\n        Args:\n            index_name: Name of the index. Default is a generated UUID.\n            doc_type: Name of the document type. Default id generic_event.\n            mappings: Optional dict with the document mapping for Elastic.\n\n        Returns:\n            Index name in string format.\n            Document type in string format.\n        '
    if mappings:
        _document_mapping = mappings
    else:
        _document_mapping = {'properties': {'timesketch_label': {'type': 'nested'}, 'datetime': {'type': 'date'}}}
    if self.version.startswith('6'):
        _document_mapping = {doc_type: _document_mapping}
    if (not self.client.indices.exists(index_name)):
        try:
            self.client.indices.create(index=index_name, body={'mappings': _document_mapping})
        except ConnectionError as e:
            raise RuntimeError('Unable to connect to Timesketch backend.') from e
        except RequestError:
            index_exists = self.client.indices.exists(index_name)
            es_logger.warning('Attempting to create an index that already exists ({0:s} - {1:s})'.format(index_name, str(index_exists)))
    return (index_name, doc_type)