Doctrine\OrientDB\Query\Query::index PHP Method

index() public method

Creates a index
public index ( string $property, string $type, string $class = null ) : Query
$property string
$type string
$class string
return Query
    public function index($property, $type, $class = null)
    {
        $commandClass = $this->getCommandClass('index.create');
        $this->command = new $commandClass($property, $type, $class);
        return $this->command;
    }

Usage Example

 public function testIndexCreate()
 {
     $binding = $this->createHttpBinding();
     $query = new Query();
     $query->index('index_name_2', 'unique');
     $result = $this->doQuery($query, $binding);
     $this->assertHttpStatus(200, $result);
     $body = $result->getData()->result[0];
     $this->assertSame(0, $body->value);
     $count = $this->getResultCount($binding->query('SELECT FROM Profile'));
     $query = new Query();
     $query->index('name', 'unique', 'Profile');
     $result = $this->doQuery($query, $binding);
     $this->assertHttpStatus(200, $result);
     $value = $result->getData()->result[0]->value;
     $this->assertEquals($value, $count);
 }