JAVA全系列 教程
3762个小节阅读:7088.9k
目录
C语言快速入门
JAVA全系列 教程
面向对象的程序设计语言
Python全系列 教程
Python3.x版本,未来主流的版本
人工智能 教程
顺势而为,AI创新未来
大厂算法 教程
算法,程序员自我提升必经之路
C++ 教程
一门通用计算机编程语言
微服务 教程
目前业界流行的框架组合
web前端全系列 教程
通向WEB技术世界的钥匙
大数据全系列 教程
站在云端操控万千数据
AIGC全能工具班
A A
White Night
MongoDB提供了针对string内容的文本查询,Text Index支持任意属性值为string或string数组元素的索引查询。注意:一个集合仅支持最多一个Text Index,中文分词不理想推荐ES
xxxxxxxxxx
db.fullText.insert({name:"aa",description:"no pains,no gains"})
db.fullText.insert({name:"ab",description:"pay pains,get gains"})
db.fullText.insert({name:"ac",description:"a friend in need,a friend in deed"})
创建索引并指定语言
xxxxxxxxxx
db.fullText.createIndex(
{ description : "text" },
{ default_language: "english" }
)
xxxxxxxxxx
db.fullText.find({"$text": {"$search": "pains"}})
全文索引名称
xxxxxxxxxx
db.collection.createIndex(
{
content: "text",
"users.comments": "text",
"users.profiles": "text"
}
)
生成的默认索引名:
xxxxxxxxxx
content_text_users.comments_text_users.profiles_text
指定名称
xxxxxxxxxx
db.collection.createIndex(
{
content: "text",
"users.comments": "text",
"users.profiles": "text"
},
{
name: "MyTextIndex"
}
)
使用指定名称删除索引
xxxxxxxxxx
db.collection.dropIndex("MyTextIndex")