Create text index with RawCommand

36 views
Skip to first unread message

zcsongor

unread,
Aug 24, 2015, 11:32:17 AM8/24/15
to ReactiveMongo - http://reactivemongo.org
Hi

I've tried to create a text index - unsuccessfully. Here's my code snippet:

val commandDoc =
 
BSONDocument(
   
"createIndexes" -> "venue",
   
"indexes" -> BSONArray(
     
BSONDocument("key" -> BSONDocument("$**" -> "text")),
     
BSONDocument("name" -> "venue_text_index")))

val futureResult = Await.ready(db.command(RawCommand(commandDoc)), Duration.Inf)

I got the following error:
Failure(reactivemongo.core.commands.DefaultCommandError: BSONCommandError['command failed because the 'ok' field is missing or equals 0'] with original doc {
  createdCollectionAutomatically: BSONBoolean(false),
  numIndexesBefore: BSONInteger(1),
  errmsg: BSONString(exception: invalid parameter: expected an object ()),
  code: BSONInteger(10065),
  ok: BSONDouble(0.0)
})

The strange thing is if I run the following command on the same collection, that's working just fine, and I got my index:
db.getSiblingDB("dbname").runCommand(
  {
    createIndexes: "venue",
    indexes: [
        {
            key: {
                "$**": "text"
            },
            name: "venue_text_index",
        }
    ]
  }
)

What did I wrong?

Many thanks,
Csongor

Cédric Chantepie

unread,
Aug 24, 2015, 3:13:40 PM8/24/15
to ReactiveMongo - http://reactivemongo.org

zcsongor

unread,
Aug 25, 2015, 4:23:07 AM8/25/15
to ReactiveMongo - http://reactivemongo.org
Many thanks!

2015. augusztus 24., hétfő 21:13:40 UTC+2 időpontban Cédric Chantepie a következőt írta:
Better to use http://reactivemongo.org/releases/0.11/api/#reactivemongo.api.indexes.IndexesManager
Reply all
Reply to author
Forward
0 new messages