Code Snippet - How to Add Index to Document at MongoDB C#

2014/3/11 min read
bookmark this
Responsive image
// add index to document's field
collection.CreateIndex(IndexKeys.Ascending(_ => _.FieldName));
// add index to subdocument's field
collection.CreateIndex("SubDocument.FieldName");