-
Type: Bug
-
Resolution: Works as Designed
-
Priority: Major - P3
-
None
-
Affects Version/s: 2.11.1
-
Component/s: Read Operations
-
None
So, based on .hint() and $hint official documentation, I'm using this query on terminal:
db.Logs.find()._addSpecial( "$hint", { $natural : -1 } )
The closest I was able to produce on C# was something like:
var options = new FindOptions { Modifiers = new MongoDB.Bson.BsonDocument("$hint", "{ $natural : -1 }") }; //let me check the "translation" var str = logCollection.Find(obj => true, options).ToString(); return logCollection.Find(obj => true, options).ToList();
This code throws the exception:
planner returned error :: caused by :: hint provided does not correspond to an existing index.'
But, the '.ToString()' method does seems to translate the command correctly:
find({ })._addSpecial("$hint", "{ $natural : -1 }")
So, if ToString() is getting it correctly, it should work, but it isn't.
On that note, shouldn't you create an C# equivalent to find().hint(index) to make it simpler to use hint ?