Atu*_*wal 0 indexing mongodb node.js
我有这样的收藏
{
"_id" : ObjectId("58492f1a23e7a2bc20a252ce"),
"type" : "valuation",
"quote" : {
"schedule" : "no",
"valuation" : "XXX",
"designation" : "III",
"companyname" : "XYZ",
"city" : "Delhi",
"country" : "India",
"phone" : "991147****",
"email" : "atul.agrawal@abc.com",
"mobile" : "991147****",
"lname" : "Agrawal",
"fname" : "Atul",
"product" : {
"contactNumberAsAbove" : true,
"contactPersonAsAbove" : true,
"description" : "Test obj",
"mfgYear" : 2009,
"city" : "Delhi",
"model" : "2518",
"brand" : "Ashtt9t",
"category" : "Tipjbih"
}
},
"createdAt" : ISODate("2016-12-08T09:59:54.686Z"),
"__v" : 0
}
{
"_id" : ObjectId("58492f8e23e7a2bc20a252d1"),
"type" : "shipping",
"quote" : {
"comment" : "Hello World",
"packaging" : "no",
"allowed" : "no",
"designation" : "II",
"companyname" : "XYZ",
"city" : "Delhi",
"country" : "India",
"phone" : "99114733**",
"email" : "atul.agrawal@xyz.com",
"mobile" : "99114733**",
"lname" : "Agrawal",
"fname" : "Atul"
},
"createdAt" : ISODate("2016-12-08T10:01:50.001Z"),
"__v" : 0
}
Run Code Online (Sandbox Code Playgroud)
现在当我做这个查询时
db.collection.find({$text:{$search:'abc@test.com'}}).pretty()
Run Code Online (Sandbox Code Playgroud)
它给了我集合中的所有文档。我还使用此查询在所有字段上制作了文本索引
db.serviceenquiries.createIndex({"$**":"text"})
Run Code Online (Sandbox Code Playgroud)
我如何搜索电子邮件 ID
尝试搜索词组:
db.collection.find({$text:{$search:"\"abc@test.com\""}}).pretty()
Run Code Online (Sandbox Code Playgroud)