我正在尝试对名为的集合进行文本搜索DAFacility
在 MongoDB 指南针中:
_id:62170597b3fa8994a0d9a0c8
author:"User"
organizationName:"TSTT"
eventName:"Facility Assessment After Disaster"
eventDate:2022-02-01T00:00:00.000+00:00
area:"Siparia"
disasterNature:"Earthquake"
threatLevel:"High"
surroundingDamage:"Cracked Foundations and Roads"
facilityName:"Point Lisas Main Facility"
facLocation:Array
facStatus:"Operable"
operEqu:23
inoperEqu:7
facilityDamage:"Cracked Walls and Floors"
facImage:Array
__v:0
我正在尝试搜索该领域facilityDamage
我可以在其中搜索整个数据条目中的一个单词(例如搜索该单词"Walls"
并显示整个条目)
我正在尝试在 mongoDB 数据聚合选项中执行它,模板为:
[
{
'$search': {
'index': 'string',
'text': {
'query': 'string',
'path': 'string'
}
}
}
]
我读过该文档,它让我对索引、查询和路径中的内容更加困惑。
你们能告诉我索引、查询和路径中包含哪些变量吗?
每当我在节点中使用它时,它都会返回一个空数组:
exports.DAEquipment_damage_search = (req, res) => {
DAEquipment.aggregate([
[
{
'$match': {
'$or': [
{'facilityDamage':{ '$regex':'.*' + req.body.facilityDamage + '.*','$options': 'i' } }
]
}
}
}
]
]).then((DAEquipment) => {
res.send(DAEquipment);
console.log(DAEquipment);
})
.catch((e) => {
res.send(e);
});
};
await DAFacility.aggregate([
{
$match: {
$or: [
{"facilityDamage":{ $regex:'.*' + searchText + '.*',$options: 'i' } },
]
}
},
])
愿它能帮助你
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)