def build(self, obj=None, queryset=None, push=True):
        """Build indexes."""
        if obj is not None and queryset is not None:
            raise ValueError(
                "Only one of 'obj' and 'queryset' parameters can be passed to the build method."
            )

        if obj is not None:
            if self.queryset.model != obj._meta.model:  # pylint: disable=protected-access
                logger.debug(
                    "Object type mismatch, skipping build of '%s' Elasticsearch index.",
                    self.__class__.__name__
                )
                return

            if not self.queryset.filter(pk=self.get_object_id(obj)).exists():
                logger.debug(
                    "Object not in predefined queryset, skipping build of '%s' Elasticsearch index.",
                    self.__class__.__name__
                )
                return

        elif queryset is not None:
            if self.queryset.model != queryset.model:
                logger.debug(
                    "Queryset type mismatch, skipping build of '%s' Elasticsearch index.",
                    self.__class__.__name__
                )
                return

        FULL_REBUILD = 'full'  # pylint: disable=invalid-name

        def handler(agg=None):
            """Index build handler."""
            if agg == FULL_REBUILD:
                queryset = self.queryset.all()
            else:
                queryset = self.queryset.none().union(*agg)

            self._build(queryset=queryset, push=push)

        def aggregator(agg=None):
            """Index build aggregator."""
            if agg == FULL_REBUILD:
                # A full rebuild is required, ignore any other builds.
                pass
            else:
                if agg is None:
                    agg = []

                if obj is not None:
                    # Build of a single object.
                    agg.append(self.queryset.filter(pk=obj.pk))
                elif queryset is not None:
                    # Build of multiple objects.
                    agg.append(queryset)
                else:
                    # Full rebuild, ignore any other builds.
                    agg = FULL_REBUILD

            return agg

        batcher = PrioritizedBatcher.global_instance()
        if batcher.is_started:
            batcher.add('resolwe.elastic', handler, group_by=(self._index_name, push), aggregator=aggregator)
        else:
            self._build(obj=obj, queryset=queryset, push=push)