protected function reduceIndexes(&$resource, array $indexNames)
    {
        $keep = [];
        $keepName = [];
        $totalReduced = 0;
        foreach ($resource->indexes as $index) {
            if (in_array($index->getName(), $indexNames) || in_array($index->getName(), $keepName)) {
                $totalReduced++;
                continue;
            }

            $keep[] = $index;
            $keepName[] = $index->getName();
        }

        $resource->indexes = $keep;

        return $totalReduced;
    }