The _id field is always indexed. Additional indexes can be created with createIndex:


<?php
$m 
= new MongoClient;
$c $m->tutorial->beer;

// Create an index on the beer name attribute
$c->createIndex( [ 'beer_name' => ] );

// Create a compound index on beer name and brewery name
$c->createIndex( [ 'beer_name' => 1'brewery_name' => ] );

// Create a unique index on the name field of the venue attribute
$c->createIndex( [ 'venue.name' => ] );
?>