Build index.

@param string          $bucketName
@param string|string[] $indexNames names of index

@return bool
@throws Exception
@throws \yii\base\InvalidConfigException
188003
public function buildIndex($bucketName, $indexNames)
    {
        $this->beginProfile($token = "    > build index $bucketName ...");

        $result = $this->db->buildIndex($bucketName, $indexNames);

        $this->endProfile($token);

        return $result;
    }
566436
public function createIndex($indexName)
    {
        $this->indexName = $indexName;

        if (file_exists($this->config['storage'].$indexName)) {
            unlink($this->config['storage'].$indexName);
        }

        $this->index = new PDO('sqlite:'.$this->config['storage'].$indexName);
        $this->index->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

        $this->index->exec("CREATE TABLE IF NOT EXISTS wordlist (
                    id INTEGER PRIMARY KEY,
                    term TEXT UNIQUE COLLATE nocase,
                    num_hits INTEGER,
                    num_docs INTEGER)");

        $this->index->exec("CREATE UNIQUE INDEX 'main'.'index' ON wordlist ('term');");

        $this->index->exec("CREATE TABLE IF NOT EXISTS doclist (
                    term_id INTEGER,
                    doc_id INTEGER,
                    hit_count INTEGER)");

        $this->index->exec("CREATE TABLE IF NOT EXISTS fields (
                    id INTEGER PRIMARY KEY,
                    name TEXT)");

        $this->index->exec("CREATE TABLE IF NOT EXISTS hitlist (
                    term_id INTEGER,
                    doc_id INTEGER,
                    field_id INTEGER,
                    position INTEGER,
                    hit_count INTEGER)");

        $this->index->exec("CREATE TABLE IF NOT EXISTS info (
                    key TEXT,
                    value INTEGER)");

        $this->index->exec("INSERT INTO info ( 'key', 'value') values ( 'total_documents', 0)");

        $this->index->exec("CREATE INDEX IF NOT EXISTS 'main'.'term_id_index' ON doclist ('term_id' COLLATE BINARY);");

        if (!$this->dbh) {
            $connector = $this->createConnector($this->config);
            $this->dbh = $connector->connect($this->config);
        }
        return $this;
    }
420678
public function dropIndex($bucketName, $indexName)
    {
        $bucketName = $this->db->quoteBucketName($bucketName);
        $indexName  = $this->db->quoteColumnName($indexName);

        return "DROP INDEX $bucketName.$indexName";
    }
542472
public function getBucketLocation($bucketName, $options = array())
    {
        list($config) = $this->parseOptions($options, BosOptions::CONFIG);
        $response = $this->sendRequest(
            HttpMethod::GET,
            array(
                BosOptions::CONFIG => $config,
                'bucket_name' => $bucketName,
                'params' => array(
                    BosOptions::LOCATION => '',
                ),
            )
        );
        return $response->locationConstraint;
    }
1190603
public function setPrimaryKey(array $columnNames, $indexName = false)
    {
        $this->_addIndex($this->_createIndex($columnNames, $indexName ?: 'primary', true, true));

        foreach ($columnNames as $columnName) {
            $column = $this->getColumn($columnName);
            $column->setNotnull(true);
        }

        return $this;
    }
50760
public function dropPrimaryIndex($bucketName)
    {
        $this->beginProfile($token = "    > drop index $bucketName ...");

        $result = $this->db->dropPrimaryIndex($bucketName);

        $this->endProfile($token);

        return $result;
    }
619351
private function writeIndex( $indexName, ezcDbSchemaIndex $index )
    {
        $this->writer->startElement( 'name' );
        $this->writer->text( $indexName );
        $this->writer->endElement();

        if ( $index->primary )
        {
            $this->writer->startElement( 'primary' );
            $this->writer->text( 'true' );
            $this->writer->endElement();
        }

        if ( $index->unique )
        {
            $this->writer->startElement( 'unique' );
            $this->writer->text( 'true' );
            $this->writer->endElement();
        }
        $this->writer->flush();

        foreach ( $index->indexFields as $fieldName => $field )
        {
            $this->writer->startElement( 'field' );
            $this->writeIndexField( $fieldName, $field );

            $this->writer->endElement();
            $this->writer->flush();
        }
    }
860107
public function createIndex($indexName, $columns, $condition = null, &$params = [], $options = [])
    {
        return $this->db->createIndex($this->name, $indexName, $columns, $condition, $params, $options);
    }
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
            );
        }
    }
1168170
public function unique(string $indexName = null)
    {
        $this->indexName = $indexName ?? $this->tableName . '_' . $this->name . '_unique_index';
        $this->isUnique  = true;

        return $this;
    }
114140
public function selectGridFSBucket(array $options = [])
    {
        $options += [
            'readConcern' => $this->readConcern,
            'readPreference' => $this->readPreference,
            'typeMap' => $this->typeMap,
            'writeConcern' => $this->writeConcern,
        ];

        return new Bucket($this->manager, $this->databaseName, $options);
    }
1326567
public function appendColumnToUniqueIndexes(string $columnName)
    {
        if (!isset($this->columns[$columnName])) {
            throw InvalidArgumentException::format(
                'Invalid column name supplied to %s: expecting one of (%s), \'%s\' given',
                __METHOD__, Debug::formatValues(array_keys($this->columns)), $columnName
            );
        }

        foreach ($this->indexes as $key => $index) {
            if ($index->isUnique()) {
                $this->indexes[$key] = new Index(
                    $index->getName(),
                    true,
                    array_unique(array_merge($index->getColumnNames(), [$columnName]))
                );
            }
        }
    }
456859
public function getIndexByName($indexName, $tableName)
    {
        $indices = $this->getIndices($tableName);

        $result = null;

        foreach ($indices as $index) {
            if ($indexName === $index['Column_name']) {
                $result = $index;
            }
        }

        return $result;
    }
795203
public function getIndex($indexName)
    {
    	if (array_key_exists($indexName, $this->indices)) {
	    	return $this->indices[$indexName];
    	}

    	return null;
    }
195883
public function createPrimaryIndex($bucketName, $indexName = null, $options = [])
    {
        $bucketName = $this->db->quoteBucketName($bucketName);

        if ($indexName) {
            $indexName  = $this->db->quoteBucketName($indexName);
        }

        $sql = "CREATE PRIMARY INDEX $indexName ON $bucketName";

        if (!empty($options)) {
            $sql .= ' WITH ' . Json::encode($options, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT);
        }

        return $sql;
    }
586370
private static function prepareIndexConfig()
    {
        foreach (self::$storage as $className => $id) {
            $key = IndexHelper::storageClassToType($className);
            $config = self::prepareMapping($className);
            if (false === empty($config)) {
                self::$indexConfig['body']['mappings'][$key] = $config;
            }
        }
        return self::$indexConfig;
    }
156075
public function indexCount($indexName)
    {
        $commandClass = $this->getCommandClass('index.count');
        $this->command = new $commandClass($indexName);

        return $this->command;
    }