(self, index_name, event_type, event=None, event_id=None,
                     flush_interval=DEFAULT_FLUSH_INTERVAL, timeline_id=None)
return self.import_counter['events']
Add event to OpenSearch.

        Args:
            index_name: Name of the index in OpenSearch
            event_type: Type of event (e.g. plaso_event)
            event: Event dictionary
            event_id: Event OpenSearch ID
            flush_interval: Number of events to queue up before indexing
            timeline_id: Optional ID number of a Timeline object this event
                belongs to. If supplied an additional field will be added to
                the store indicating the timeline this belongs to.
Add event to OpenSearch.
Add event to OpenSearch .
def import_event(self, index_name, event_type, event=None, event_id=None,
                     flush_interval=DEFAULT_FLUSH_INTERVAL, timeline_id=None):
        """Add event to OpenSearch.

        Args:
            index_name: Name of the index in OpenSearch
            event_type: Type of event (e.g. plaso_event)
            event: Event dictionary
            event_id: Event OpenSearch ID
            flush_interval: Number of events to queue up before indexing
            timeline_id: Optional ID number of a Timeline object this event
                belongs to. If supplied an additional field will be added to
                the store indicating the timeline this belongs to.
        """
        if event:
            for k, v in event.items():
                if not isinstance(k, six.text_type):
                    k = codecs.decode(k, 'utf8')

                # Make sure we have decoded strings in the event dict.
                if isinstance(v, six.binary_type):
                    v = codecs.decode(v, 'utf8')

                event[k] = v

            # Header needed by OpenSearch when bulk inserting.
            header = {
                'index': {
                    '_index': index_name,
                }
            }
            update_header = {
                'update': {
                    '_index': index_name,
                    '_id': event_id
                }
            }

            # TODO: Remove when we deprecate Elasticsearch version 6.x
            if self.version.startswith('6'):
                header['index']['_type'] = event_type
                update_header['update']['_type'] = event_type

            if event_id:
                # Event has "lang" defined if there is a script used for import.
                if event.get('lang'):
                    event = {'script': event}
                else:
                    event = {'doc': event}
                header = update_header

            if timeline_id:
                event['__ts_timeline_id'] = timeline_id

            self.import_events.append(header)
            self.import_events.append(event)
            self.import_counter['events'] += 1

            if self.import_counter['events'] % int(flush_interval) == 0:
                _ = self.flush_queued_events()
                self.import_events = []
        else:
            # Import the remaining events in the queue.
            if self.import_events:
                _ = self.flush_queued_events()

        return self.import_counter['events']
def import_event ( self , index_name , event_type , event = None , event_id = None , flush_interval = DEFAULT_FLUSH_INTERVAL , timeline_id = None ) : if event : for k , v in event . items ( ) : if not isinstance ( k , six . text_type ) : k = codecs . decode ( k , 'utf8' ) # Make sure we have decoded strings in the event dict. if isinstance ( v , six . binary_type ) : v = codecs . decode ( v , 'utf8' ) event [ k ] = v # Header needed by OpenSearch when bulk inserting. header = { 'index' : { '_index' : index_name , } } update_header = { 'update' : { '_index' : index_name , '_id' : event_id } } # TODO: Remove when we deprecate Elasticsearch version 6.x if self . version . startswith ( '6' ) : header [ 'index' ] [ '_type' ] = event_type update_header [ 'update' ] [ '_type' ] = event_type if event_id : # Event has "lang" defined if there is a script used for import. if event . get ( 'lang' ) : event = { 'script' : event } else : event = { 'doc' : event } header = update_header if timeline_id : event [ '__ts_timeline_id' ] = timeline_id self . import_events . append ( header ) self . import_events . append ( event ) self . import_counter [ 'events' ] += 1 if self . import_counter [ 'events' ] % int ( flush_interval ) == 0 : _ = self . flush_queued_events ( ) self . import_events = [ ] else : # Import the remaining events in the queue. if self . import_events : _ = self . flush_queued_events ( ) return self . import_counter [ 'events' ]