gpt4 book ai didi

node.js - 电子邮件 ID 搜索在 mongodb 全文搜索中不起作用

转载 作者:太空宇宙 更新时间:2023-11-04 03:05:48 25 4
gpt4 key购买 nike

我的收藏是这样的

{
"_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
}

现在当我提出这个查询时

db.collection.find({$text:{$search:'abc@test.com'}}).pretty()

它为我提供了集合中的所有文档。我还使用此查询在所有字段上创建了文本索引

db.serviceenquiries.createIndex({"$**":"text"})

如何搜索电子邮件 ID

最佳答案

尝试搜索短语:

db.collection.find({$text:{$search:"\"abc@test.com\""}}).pretty()

关于node.js - 电子邮件 ID 搜索在 mongodb 全文搜索中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41183157/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com