@param array $indexes

@throws \InvalidArgumentException
514951
public function setIndexes(array $indexes)
    {
        foreach ($indexes as $identifier => $index) {
            if (!isset($index['path'])) {
                throw new \InvalidArgumentException('Each lucene index must have a path value.');
            }

            $this->setIndex(
                $identifier,
                $index['path'],
                isset($index['analyzer']) ? $index['analyzer'] : self::DEFAULT_ANALYZER,
                isset($index['max_buffered_docs']) ? $index['max_buffered_docs'] : self::DEFAULT_MAX_BUFFERED_DOCS,
                isset($index['max_merge_docs']) ? $index['max_merge_docs'] : self::DEFAULT_MAX_MERGE_DOCS,
                isset($index['merge_factor']) ? $index['merge_factor'] : self::DEFAULT_MERGE_FACTOR,
                isset($index['permissions']) ? $index['permissions'] : self::DEFAULT_PERMISSIONS,
                isset($index['auto_optimized']) ? $index['auto_optimized'] : self::DEFAULT_AUTO_OPTIMIZED,
                isset($index['query_parser_encoding']) ? $index['query_parser_encoding'] : self::DEFAULT_QUERY_PARSER_ENCODING
            );
        }
    }
16064
public function createIndexes(array $indexes, array $options = [])
    {
        if (empty($indexes)) {
            throw new InvalidArgumentException('$indexes array cannot be empty.');
        }

        $compiledIndexes = array_map(function (Index $index) {
            return $index->toArray();
        }, $indexes);

        $this->executeCommand(
            ['createIndexes' => $this->collectionName, 'indexes' => $compiledIndexes],
            $options
        );

        return array_map(function (Index $index) {
            return $index->getName();
        }, $indexes);
    }
1287322
public function rotate($indexes)
    {

        $pb = $this->prepareProcessBuilder();

        if (is_array($indexes)) {
            foreach ($indexes as &$label) {
                if (isset($this->indexes[$label])) {
                    $pb->add($this->indexes[$label]);
                }
            }
        } elseif (is_string($indexes)) {
            if (isset($this->indexes[$indexes])) {
                $pb->add($this->indexes[$indexes]);
            }
        } else {
            throw new \RuntimeException(sprintf(
                'Indexes can only be an array or string, %s given.',
                gettype($indexes)
            ));
        }

        $indexer = $pb->getProcess();
        $indexer->run();

        if (strstr($indexer->getOutput(), 'FATAL:') || strstr($indexer->getOutput(), 'ERROR:')) {
            throw new \RuntimeException(sprintf('Error rotating indexes: "%s".', rtrim($indexer->getOutput())));
        }
    }
1160297
public function setSchemaDirs(array $dirs)
    {
        foreach ($dirs as $dir) {
            if (!is_dir($dir)) {
                throw new \InvalidArgumentException(sprintf('The directory "%s" does not exist.', $dir));
            }
        }

        $this->schemaDirs = $dirs;

        return $this;
    }
1144839
public function deleteIndex($keys)
    {
        if (is_string($keys)) {
            $indexName = $keys;
            if (! preg_match('#_-?1$#', $indexName)) {
                $indexName .= '_1';
            }
        } elseif (is_array($keys)) {
            $indexName = \MongoDB\generate_index_name($keys);
        } else {
            throw new \InvalidArgumentException();
        }

        try {
            return TypeConverter::toLegacy($this->collection->dropIndex($indexName));
        } catch (\MongoDB\Driver\Exception\Exception $e) {
            return ExceptionConverter::toResultArray($e) + ['nIndexesWas' => count($this->getIndexInfo())];
        }
    }
424086
public function createTextIndexes(array $textIndexes)
    {
        if (!empty($textIndexes)) {
            $sm = $this->getSchemaManager();
            foreach ($textIndexes as $tableName => $indexes) {
                if ($sm->tablesExist([$tableName])) {
                    $existingIndexNames = array_map(
                        function (\Doctrine\DBAL\Schema\Index $index) {
                            return $index->getShortestName('');
                        },
                        $sm->listTableIndexes($tableName)
                    );
                    $chunks = [];
                    foreach ($indexes as $indexName => $indexColumns) {
                        if (!in_array(strtolower($indexName), $existingIndexNames, true)) {
                            $newIndexColumns = [];
                            foreach ((array) $indexColumns as $indexColumn) {
                                $indexColumn = (array) $indexColumn;
                                $s = $this->quoteIdentifier($indexColumn[0]);
                                if (!empty($indexColumn[1])) {
                                    $s .= '(' . (int) $indexColumn[1] . ')';
                                }
                                $newIndexColumns[] = $s;
                            }
                            $chunks[] = $this->quoteIdentifier($indexName) . ' (' . implode(', ', $newIndexColumns) . ')';
                        }
                    }
                    if (!empty($chunks)) {
                        $sql = 'ALTER TABLE ' . $this->quoteIdentifier($tableName) . ' ADD INDEX ' . implode(', ADD INDEX ', $chunks);
                        $this->executeQuery($sql);
                    }
                }
            }
        }
    }
95098
public function addSecondaryIndex(Index $index)
    {
        if ($this->isEmbeddedDocument) {
            throw MappingException::embeddedDocumentsNotIndexable($this->getName());
        }

        if (isset($this->secondaryIndexes[$index->getName()])) {
            throw MappingException::indexExists($this->getName(), $index->getName());
        }

        $this->secondaryIndexes[$index->getName()] = $index;
    }
168678
public function setRepositories($repositories)
    {
        if (!is_array($repositories) && (!is_object($repositories) || !$repositories instanceof \Traversable)) {
            throw new InvalidArgumentException(sprintf(
                'Invalid argument provided for $repositories, expecting either an array or Traversable object, but' .
                ' "%s" given',
                is_object($repositories) ? get_class($repositories) : gettype($repositories)
            ));
        }
        $this->stack = new \SplStack();
        $this->addRepositories($repositories);
    }
1348757
private function setRuleIndexes(array $ruleIndexes): self
    {
        assert($this->debugCheckIndexesExist($ruleIndexes));

        $this->ruleIndexes     = $ruleIndexes;
        $this->ruleMainIndexes = $this->getSerializer()::readRuleMainIndexes($ruleIndexes);

        return $this;
    }
1269976
public function execute($ids)
    {
        $storeIds = array_keys($this->storeManager->getStores());

        foreach ($storeIds as $storeId) {
            $dimension = $this->dimensionFactory->create(['name' => 'scope', 'value' => $storeId]);
            $this->indexerHandler->deleteIndex([$dimension], new \ArrayObject($ids));
            $this->indexerHandler->saveIndex([$dimension], $this->fullAction->rebuildStoreIndex($storeId, $ids));
        }
    }
1287017
final public function addIndex(Index $index): Table
    {
        if ($this->hasIndex($index::getName())) {
            throw new InvalidArgumentException('Foreign key '.$index::getName().' already exists in the table '.$this::getName());
        }

        $this->indexes[$index::getName()] = $index;

        return $this;
    }
993398
protected function addIndexes(&$properties, array $indexes, array $validColumns)
    {
        foreach ($indexes as $index) {
            if (!$index->hasColumns()) {
                continue;
            }

            $indexName = '';
            if ($index->hasName()) {
                $indexName = sprintf(", '%s'", $index->getName());
            }

            if ($index->hasMultipleColumns()) {
                $invalidColumns = array_diff($index->getColumns(), $validColumns);

                if (count($invalidColumns) > 0) {
                    throw new Exception('Non-Existing columns are being using an index. Invalid columns are "' . implode(',', $invalidColumns) . '"');
                }

                $columns = Helpers::wrapItems($index->getColumns());

                $indexColumn = sprintf('[%s]', implode(',', $columns));
            } else {
                $column = $index->getFirstColumn();

                if (!in_array($column, $validColumns)) {
                    throw new Exception('Non-Existing column is being using an index. Invalid columns is ' . $column);
                }
                $indexColumn = sprintf("'%s'", $column);
            }

            $properties .= sprintf('%s(%s%s)', $this->getPropertyBase($index->getType()), $indexColumn, $indexName);

            $this->addFieldPropertyClousure($properties);
        }

        return $this;
    }
1150184
public function setLoaders(array $loaders)
    {
        $this->loaders = array();
        foreach ($loaders as $type=>$loader) {
            if (!$loader instanceof ResourceLoaderInterface) {
                throw new \InvalidArgumentException("Not a valid resource loader.");
            }
            $this->loaders[$type] = $loader;
        }
    }
685147
private function loadIndexes(): void
    {
        if (null !== $this->gsi) {
            return;
        }

        $this->gsi = [];
        foreach ($this->getIndexes() as $gsi) {
            $this->gsi[$gsi->getAlias()] = $gsi;
        }
    }
1128085
public function saveAll(array $entities): void
    {
        if ([] === $entities) {
            return;
        }
        foreach ($entities as $entity) {
            if (false === $entity instanceof EntityInterface) {
                throw new \InvalidArgumentException(
                    'Found invalid $entity was not an EntityInterface, was ' . \get_class($entity)
                );
            }
            $this->entityManager->persist($entity);
        }
        $this->entityManager->flush();
    }
196487
public function insureIsFilled($indexes, $defaultValue)
    {
        $newValues = [];
        foreach ($indexes as $index) {
            $newValues[$index] = array_key_exists($index, $this->values) ? $this->values[$index] : $defaultValue;
        }
        $this->values = $newValues;
    }
738808
public function isIndex(array $keys)
    {
        if ($this->indices) {
            foreach ($this->indices as $index) {
                if (count($keys) === count($index->getColumns())) {
                    $allAvailable = true;
                    foreach ($keys as $key) {
                        if (!$index->hasColumn($key instanceof Column ? $key->getName() : $key)) {
                            $allAvailable = false;
                            break;
                        }
                    }
                    if ($allAvailable) {
                        return true;
                    }
                }
            }
        }

        return false;
    }