0
votes

I have this document Scheme: use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;

/**
 * @MongoDB\Document(collection="users") *
 */
class Markers
{
    /**
     * @MongoDB\Id
     */
    protected $id;
    /**
     * @MongoDB\Float
     */
    protected $lat;
    /**
     * @MongoDB\Float
     */
    protected $lng;
    /**
     * @MongoDB\String
     */
    protected $title;
}

What I want is having index on $title field and $lat and $lng how do you suggest I should work this out ? Do I have to tell the document that these fields are indexes or , running the command in Mongo shell is sufficient ? Thanks !

1

1 Answers

0
votes

You can define indexes in Mongo shell and make it independent from code implementation. Your database would be accessible from different systems and mantain consistency in its administration.

¿Have you considered the use of geospacial indexes for lng and lat?