I am using the MongoDB driver for ASP.NET Core 2.0 with C# and I was wondering if I can create an index on the type discriminator filed (that _t field added by mongo itself that hold the class name of the object).
I have data from different types and I want to be able to filter it fasterr based on its type.
Thanks in advance!
if I can create an index on the type discriminator filed (that _t field added by mongo itself that hold the class name of the object).
Hi Kaloyan,
It’s been a while since you posted your question, have you found a solution yet ?
The discriminator field is created by the MongoDB .Net/C# driver. You can create the index directly using db.collection.createIndex() via mongo shell. For example:
db.collectionName.createIndex({_t:1})
Regards,
Wan.