db.reviews.createIndex( { comments: "text" } )
操作符 | 解释 |
---|---|
$text | 在有text index的集合上执行文本检索。$text将会使用空格和标点符号作为分隔符对检索字符串进行分词, 并且对检索字符串中所有的分词结果进行一个逻辑上的 OR 操作。 |
db.stores.insert(
[
{ _id: 1, name: "Java Hut", description: "Coffee and cakes" },
{ _id: 2, name: "Burger Buns", description: "Gourmet hamburgers" },
{ _id: 3, name: "Coffee Shop", description: "Just coffee" },
{ _id: 4, name: "Clothes Clothes Clothes", description: "Discount clothing"},
{ _id: 5, name: "Java Shopping", description: "Indonesian goods" }
]
)
> db.stores.find()
db.stores.createIndex({name: "text", description: "text"})
> db.stores.getIndexes()
> db.stores.find({$text: {$search: "java coffee shop"}})
版权说明 : 本文为转载文章, 版权归原作者所有 版权申明
原文链接 : https://wwwxz.blog.csdn.net/article/details/124561140
内容来源于网络,如有侵权,请联系作者删除!