views:

127

answers:

2

Hey all,

I have a mondoDB with data in it at the moment which I am querying with Ruby on Rails. I am looking to index the database to speed things up a bit.

I read the mongoDB documentation and followed the instructions on how to add a index, like so:

db.collection.ensureIndex({"key": 1})

This returns true and returns this in the console:

building new index on { key: 1.0 } for db.collection...done for 10192 records

However, when I go back to the Ruby on Rails application no results are return and when I drop the indexes everything returns back to normal.

Does anyone know why this might be happening.

Cheers

Eef

A: 

What version of the db are you using? Can you send a sample object and the results of the query beforehand?

Here is the object:{"_id" : ObjectId( "bf116d38c115054b2d77a700") , "timestamp" : "Thu Nov 19 2009 09:54:09 GMT+0000 (BST)" , "severity" : "ERROR" , "thread" : "main" , "message" : "Context initialization failed" ,"lineNumber" : "215"}I am trying to index the severity key, like below:db.collection.ensureIndex({"severity": 1})Version of mongoDB I am using is MongoDB shell version: 1.0.0
Eef
+2  A: 

more info would help such as some output from the shell with the query, its output, ensureindex, then query output again, and detailed version #s

you can get help in http://groups.google.com/group/mongodb-user or on the IRC channel

dm
you might want to try upgrading too
dm
Thanks mate. Upgrading done the trick.
Eef