...
2015-05-11T17:02:29.804+0200 I INDEX [conn24] build index on: mydb.mycol properties: { v: 1, key: { i: 1 }, name: "test_index", ns: "mydb.mycol" } 2015-05-11T17:02:29.804+0200 I INDEX [conn24] building index using bulk method 2015-05-11T17:02:29.805+0200 I INDEX [conn24] build index done. scanned 101 total records. 0 secs 2015-05-11T17:02:29.806+0200 I QUERY [conn24] assertion 17007 Unable to execute query: error processing query: ns=mydb.mycol limit=0 skip=0 Tree: $and Sort: {} Proj: {} planner returned error: bad hint ns:mydb.mycol query:{ $hint: { test_index: 1 }, $query: {} } I see this when using the mongoshell as well as with PyMongo and TxMongo. The query works when using: { $hint: { i: 1 }, $query: {} }
ramon.fernandez commented on Thu, 14 May 2015 22:10:47 +0000: Understood, thanks for getting back to us psi29a. Closing this ticket now. psi29a commented on Thu, 14 May 2015 20:41:39 +0000: If that is the case, then no worries. No reason to spend any more time on this. We've corrected it on TxMongo's side to follow your lead on hinting. https://github.com/twisted/txmongo/commit/0d5d180b580e90c3c35a4126cd8708ad8409ddfb Cheers and thanks for the help! ramon.fernandez commented on Wed, 13 May 2015 19:59:44 +0000: I can't get that syntax to work in the shell in 2.6.9; I also tried with pymongo 2.7.2, but no luck either. Given the rules on hinting I would guess it was a bug that got corrected at some point during the MongoDB 2.7 development cycle. If you're interested in the details we'd need a full reproducer, including the the exact versions of pymongo and MongoDB you're using, as we have not been successful reproducing on our end. Thanks, Ramón. psi29a commented on Tue, 12 May 2015 07:59:18 +0000: Why did this work on MongoDB 2.6 and not on 3.0 ? $hint: { test_index: 1 }, $query: {} test_index is the named index. psi29a commented on Mon, 11 May 2015 16:27:44 +0000: I see the problem now, my code was sending this: {'$hint': {'email': 1}, '$query': {'external_ids.email': 'test@email'}} while it should be: {'$hint': 'email'}, '$query': {'external_ids.email': 'test@email'}} It looks like this behaviour has changed from 2.6 to 3.0. Right? ramon.fernandez commented on Mon, 11 May 2015 15:40:53 +0000: Can you please send the code you're using? I can reproduce this assertion (both in 3.0.2 and 2.6.9) when using the wrong syntax for hinting using the index name: > db.foo.drop() > for (i=0;i<200; i++) { db.foo.insert({x:i})} > db.foo.ensureIndex({x:1}, {name:"test_index"}) // This works: > db.foo.find({x:{$gte:50}}).hint({x:1}) // This doesn't because of incorrect syntax: > db.foo.find({x:{$gte:50}}).hint({"test_index":1}) error: { "$err" : "Unable to execute query: error processing query: ns=test.foo limit=0 skip=0\nTree: x $gte 50.0\nSort: {}\nProj: {}\n planner returned error: bad hint", "code" : 17007 } // With the right syntax things work: > db.foo.find({x:{$gte:50}}).hint("test_index") psi29a commented on Mon, 11 May 2015 15:11:13 +0000: This worked on MongoDB 2.6
db version v3.0.2 git version: 83419b7d5a78599e4b8449e10b0d38878ce624c0 OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014