def _build(self, obj=None, queryset=None, push=True):
        """Build indexes."""
        logger.debug("Building '%s' Elasticsearch index...", self.__class__.__name__)

        if obj is not None:
            build_list = [obj]

        elif queryset is not None:
            build_list = self.queryset.intersection(queryset)

            logger.debug("Found %s elements to build.", build_list.count())

        else:
            build_list = self.queryset.all()

            logger.debug("Found %s elements to build.", build_list.count())

        for obj in build_list:
            if self.filter(obj) is False:
                continue

            try:
                obj = self.preprocess_object(obj)
            except Exception:  # pylint: disable=broad-except
                logger.exception(
                    "Error occurred while preprocessing '%s' Elasticsearch index.",
                    self.__class__.__name__,
                    extra={'object_type': self.object_type, 'obj_id': obj.pk}
                )

            try:
                self.process_object(obj)
            except Exception:  # pylint: disable=broad-except
                logger.exception(
                    "Error occurred while processing '%s' Elasticsearch index.",
                    self.__class__.__name__,
                    extra={'object_type': self.object_type, 'obj_id': obj.pk}
                )

        logger.debug("Finished building '%s' Elasticsearch index.", self.__class__.__name__)

        if push:
            self.push()
def _build ( self , obj = None , queryset = None , push = True ) : logger . debug ( "Building '%s' Elasticsearch index..." , self . __class__ . __name__ ) if obj is not None : build_list = [ obj ] elif queryset is not None : build_list = self . queryset . intersection ( queryset ) logger . debug ( "Found %s elements to build." , build_list . count ( ) ) else : build_list = self . queryset . all ( ) logger . debug ( "Found %s elements to build." , build_list . count ( ) ) for obj in build_list : if self . filter ( obj ) is False : continue try : obj = self . preprocess_object ( obj ) except Exception : logger . exception ( "Error occurred while preprocessing '%s' Elasticsearch index." , self . __class__ . __name__ , extra = { 'object_type' : self . object_type , 'obj_id' : obj . pk } ) try : self . process_object ( obj ) except Exception : logger . exception ( "Error occurred while processing '%s' Elasticsearch index." , self . __class__ . __name__ , extra = { 'object_type' : self . object_type , 'obj_id' : obj . pk } ) logger . debug ( "Finished building '%s' Elasticsearch index." , self . __class__ . __name__ ) if push : self . push ( )
Build indexes.