ensureIndex does not take an "options" object?

328 views
Skip to first unread message

Keith Irwin

unread,
Jul 2, 2011, 4:06:32 PM7/2/11
to mongodb-ca...@googlegroups.com
Hello!

I need to "ensure" an index but because the table has 30 million objects in it, I want the indexing operation (if needed) to run in the background. 


According to the Java driver you can call ensureIndex with two parameters, a list of of indexes, and a list of options:

  http://api.mongodb.org/java/current/com/mongodb/DBCollection.html#ensureIndex(com.mongodb.DBObject,%20com.mongodb.DBObject)

I'm not seeing this with the Casbah version. Am I missing something? Or is this a missing feature that should be added?

Here's what I want to be able to do:

  val indexes = MongoDBObject("foo" -> 1, "location" -> "2d")
  val options = MongoDBObject("background" -> true)

  collection.ensureIndex(indexes, options)

I suppose I can use createIndex, which in my particular circumstance might be okay, or collection.underlying, but, still...

Keith

Brendan W. McAdams

unread,
Jul 2, 2011, 4:32:30 PM7/2/11
to mongodb-ca...@googlegroups.com

Which version?  Im out of the house right now aand can't check  but if its missing ill push you out a patch release.

Keith Irwin

unread,
Jul 2, 2011, 4:39:48 PM7/2/11
to mongodb-ca...@googlegroups.com
On Jul 2, 2011, at 1:32 PM, Brendan W. McAdams wrote:

Which version?  Im out of the house right now aand can't check  but if its missing ill push you out a patch release.

According to my build.sbt, I'm using 2.1.5.0.

According to (http://api.mongodb.org/scala/casbah/) this is the most recent release (if I'm reading that correctly).

I'm using the "underlying" method, which works just fine. Please don't push out a special fix-up just for me. If you think it's a good thing to add, the "next version" is soon enough, especially if I'm the only one using it.

I can post this as an issue in Github if you want.

Keith
Reply all
Reply to author
Forward
0 new messages