(
            self, index_name=uuid4().hex, doc_type='generic_event',
            mappings=None)
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 OpenSearch.

        Returns:
            Index name in string format.
            Document type in string format.
Create index with Timesketch settings.
Create index with Timesketch settings .
def create_index(
            self, index_name=uuid4().hex, doc_type='generic_event',
            mappings=None):
        """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 OpenSearch.

        Returns:
            Index name in string format.
            Document type in string format.
        """
        if mappings:
            _document_mapping = mappings
        else:
            _document_mapping = {
                'properties': {
                    'timesketch_label': {
                        'type': 'nested'
                    },
                    'datetime': {
                        'type': 'date'
                    }
                }
            }

        # TODO: Remove when we deprecate OpenSearch version 6.x
        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
def create_index ( self , index_name = uuid4 ( ) . hex , doc_type = 'generic_event' , mappings = None ) : if mappings : _document_mapping = mappings else : _document_mapping = { 'properties' : { 'timesketch_label' : { 'type' : 'nested' } , 'datetime' : { 'type' : 'date' } } } # TODO: Remove when we deprecate OpenSearch version 6.x 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