简体   繁体   中英

How do you create a full text search for all text fields in a mongo collection in the c# driver?

I feel like this should be really simple, yet I've had a google and can't find exactly what I'm looking for.

I can apply the following code in the mongo console:

db.collection.createIndex( { "$**": "text" } )

and I'll get a full text index on all text fields in my collection. How do I achieve this same result on a given collection in the ?的给定集合上实现相同的结果?

you can create a wildcard text index with the following.

     collection.Indexes.CreateOne(
         new CreateIndexModel<MyType>(
             Builders<MyType>.IndexKeys.Text("$**")));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM