Samstag, 25. Februar 2012

Symfony2 & MongoDb & Indices

I'm right now creating a application using symfony2 and MongoDb. I'm new to MongoDb and have a long history with relational databases, so I struggle with some details on how non-relational databases work.

One particular problem was that no matter how I defined indices in my documents, they wouldn't show up in my database and would not work at all. I didn't got any exception, so I was a little lost.

After an hour of research I found I have to create the database with the following command in order to get the indices work:
php app/console doctrine:mongodb:schema:create

The "problem" is that as Mongodb creates databases and collections on the fly you don't need to create them. On the other hand if you don't create them manually, the indices are not created with the collection.

I hope this information helps someone also struggling with it.

Keine Kommentare:

Kommentar veröffentlichen