public function createIndex($key, array $options = [])
    {
        $commandOptionKeys = ['maxTimeMS' => 1, 'session' => 1, 'writeConcern' => 1];
        $indexOptions = array_diff_key($options, $commandOptionKeys);
        $commandOptions = array_intersect_key($options, $commandOptionKeys);

        return current($this->createIndexes([['key' => $key] + $indexOptions], $commandOptions));
    }
public function createIndex($key, array $options = [])
    {
        $commandOptionKeys = ['maxTimeMS' => 1, 'session' => 1, 'writeConcern' => 1];
        $indexOptions = array_diff_key($options, $commandOptionKeys);
        $commandOptions = array_intersect_key($options, $commandOptionKeys);

        return current($this->createIndexes([['key' => $key] + $indexOptions], $commandOptions));
    }
public function createIndex ( $ key , array $ options = [ ] ) { $ commandOptionKeys = [ 'maxTimeMS' => 1 , 'session' => 1 , 'writeConcern' => 1 ] ; $ indexOptions = array_diff_key ( $ options , $ commandOptionKeys ) ; $ commandOptions = array_intersect_key ( $ options , $ commandOptionKeys ) ; return current ( $ this -> createIndexes ( [ [ 'key' => $ key ] + $ indexOptions ] , $ commandOptions ) ) ; }
Create a single index for the collection.

@see Collection::createIndexes()
@see CreateIndexes::__construct() for supported command options
@param array|object $key     Document containing fields mapped to values,
which denote order or an index type
@param array        $options Index and command options
@return string The name of the created index
@throws UnsupportedException if options are not supported by the selected server
@throws InvalidArgumentException for parameter/option parsing errors
@throws DriverRuntimeException for other driver errors (e.g. connection errors)
Create a single index for the collection .