- 创建索引

- 单字段创建索引:

db.peoples.createIndex({article: "text"})

  

- 多字段创建索引:

db.peoples.createIndex( { chinaName: "text"  , article: "text" } )

 

- 全部字段创建索引:

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

 

- 删除索引:

db.peoples.dropIndex("article_text")

 

- 根据索引进行全文搜索:$text: {$search: {...}}

  - 基本使用:

db.peoples.find({$text : {$search : 'util模块'}})

 

相关文章: