mongodb全文索引舉例

索引的創建
```
db.project.createIndex({name:"text",description:"text"})
```
基於索引分詞進行查詢
```
db.project.find({$text:{$search:"java jquery"}})
```
   基於索引 短語
```
db.project.find({$text:{$search:"\"Apache ZooKeeper\""}})
```
過濾指定單詞
```
db.project.find({$text:{$search:"java apache -阿里"}})
```
查看執行計劃
```
db.project.find({$text:{$search:"java -阿里"}}).explain("executionStats")

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章