I'm working with MongoDB in Visual Studio, using the C# 2.0.0 driver. (I am new to MongoDB 3.* and new to visual studio / C#, but somewhat experienced in python, java, and MongoDB 2.6)
I'm working on a research related topic, and therefore need to be able to specify which index the operation should use AND get the explained result. (I want to get the explain BsonDocument, not the matching docs.)
I know how to do either one of them, for ex to get explain: (here also projecting into a BsonDocument since collection isn't of type BsonDocument)
var options = new FindOptions
{
Modifiers = new BsonDocument("$explain", true)
};
BsonDocument explain = await coll.Find(filter, options).Project(new BsonDocument()).FirstOrDefaultAsync();
or use a specified index:
var options = new FindOptions
{
Modifiers = new BsonDocument("$hint", "IndexName")
};
var cursor = await coll.Find(filter, options).ToListAsync();
But I don't understand how to add the index hint to the Modifier parameter as well?
Is it possible to do both?