如何优化MongoDB的全文索引效果?
- 内容介绍
- 文章标签
- 相关推荐
本文共计218个文字,预计阅读时间需要1分钟。
全文索引创建与使用:创建全文索引:`db.document.ensureIndex({key: text})`查询示例:`db.document.find({$test: {$search: aa}})` 注意:`aa` 为要查找的内容。
全文索引:创建:db.document.ensureIndex({key:text})使用:db.document.find({$test:{$search:aa}})全文索引:
创建:db.document.ensureIndex({"key":"text"})
使用:db.document.find({$test:{$search:"aa"}})
注:aa为要查找的内容
全文索引相识度:
$meta操作符:{score:{$meta:"testscore"}}
写在查询条件后面可以返回返回结果的相识度,与sort()一起使用可以达到很好的效果。
本文共计218个文字,预计阅读时间需要1分钟。
全文索引创建与使用:创建全文索引:`db.document.ensureIndex({key: text})`查询示例:`db.document.find({$test: {$search: aa}})` 注意:`aa` 为要查找的内容。
全文索引:创建:db.document.ensureIndex({key:text})使用:db.document.find({$test:{$search:aa}})全文索引:
创建:db.document.ensureIndex({"key":"text"})
使用:db.document.find({$test:{$search:"aa"}})
注:aa为要查找的内容
全文索引相识度:
$meta操作符:{score:{$meta:"testscore"}}
写在查询条件后面可以返回返回结果的相识度,与sort()一起使用可以达到很好的效果。

