(self, searchindex_id, event_id, event_type, sketch_id,
                  user_id, label, toggle=False, remove=False,
                  single_update=True)
return None
Set label on event in the datastore.

        Args:
            searchindex_id: String of OpenSearch index id
            event_id: String of OpenSearch event id
            event_type: String of OpenSearch document type
            sketch_id: Integer of sketch primary key
            user_id: Integer of user primary key
            label: String with the name of the label
            remove: Optional boolean value if the label should be removed
            toggle: Optional boolean value if the label should be toggled
            single_update: Boolean if the label should be indexed immediately.

        Returns:
            Dict with updated document body, or None if this is a single update.
Set label on event in the datastore.
Set label on event in the datastore .
def set_label(self, searchindex_id, event_id, event_type, sketch_id,
                  user_id, label, toggle=False, remove=False,
                  single_update=True):
        """Set label on event in the datastore.

        Args:
            searchindex_id: String of OpenSearch index id
            event_id: String of OpenSearch event id
            event_type: String of OpenSearch document type
            sketch_id: Integer of sketch primary key
            user_id: Integer of user primary key
            label: String with the name of the label
            remove: Optional boolean value if the label should be removed
            toggle: Optional boolean value if the label should be toggled
            single_update: Boolean if the label should be indexed immediately.

        Returns:
            Dict with updated document body, or None if this is a single update.
        """
        # OpenSearch painless script.
        update_body = {
            'script': {
                'lang': 'painless',
                'source': UPDATE_LABEL_SCRIPT,
                'params': {
                    'timesketch_label': {
                        'name': str(label),
                        'user_id': user_id,
                        'sketch_id': sketch_id
                    },
                    remove: remove
                }
            }
        }

        if toggle:
            update_body['script']['source'] = TOGGLE_LABEL_SCRIPT

        if not single_update:
            script = update_body['script']
            return dict(
                source=script['source'], lang=script['lang'],
                params=script['params']
            )

        doc = self.client.get(
            index=searchindex_id, id=event_id, doc_type='_all')
        try:
            doc['_source']['timesketch_label']
        except KeyError:
            doc = {'doc': {'timesketch_label': []}}
            self.client.update(
                index=searchindex_id,
                doc_type=event_type,
                id=event_id,
                body=doc)

        self.client.update(
            index=searchindex_id,
            id=event_id,
            doc_type=event_type,
            body=update_body)

        return None
def set_label ( self , searchindex_id , event_id , event_type , sketch_id , user_id , label , toggle = False , remove = False , single_update = True ) : # OpenSearch painless script. update_body = { 'script' : { 'lang' : 'painless' , 'source' : UPDATE_LABEL_SCRIPT , 'params' : { 'timesketch_label' : { 'name' : str ( label ) , 'user_id' : user_id , 'sketch_id' : sketch_id } , remove : remove } } } if toggle : update_body [ 'script' ] [ 'source' ] = TOGGLE_LABEL_SCRIPT if not single_update : script = update_body [ 'script' ] return dict ( source = script [ 'source' ] , lang = script [ 'lang' ] , params = script [ 'params' ] ) doc = self . client . get ( index = searchindex_id , id = event_id , doc_type = '_all' ) try : doc [ '_source' ] [ 'timesketch_label' ] except KeyError : doc = { 'doc' : { 'timesketch_label' : [ ] } } self . client . update ( index = searchindex_id , doc_type = event_type , id = event_id , body = doc ) self . client . update ( index = searchindex_id , id = event_id , doc_type = event_type , body = update_body ) return None