protected function processIndex(
        LoggerInterface $logger,
        SolrIndex $indexInstance,
        $batchSize,
        $taskName,
        $classes = null
    ) {
        // Filter classes for this index
        $indexClasses = $this->getClassesForIndex($indexInstance, $classes);

        // Clear all records in this index which do not contain the given classes
        $logger->info("Clearing obsolete classes from " . $indexInstance->getIndexName());
        $indexInstance->clearObsoleteClasses($indexClasses);

        // Build queue for each class
        foreach ($indexClasses as $class => $options) {
            $includeSubclasses = $options['include_children'];

            foreach (SearchVariant::reindex_states($class, $includeSubclasses) as $state) {
                $this->processVariant($logger, $indexInstance, $state, $class, $includeSubclasses, $batchSize, $taskName);
            }
        }
    }