1
我想在猫鼬中使用`$文本,但它总是向我显示错误。
模型/方案:
var thSchema2=new Schema({
userid:{ type: String, unique: true,index: true},
password:String,
name:String,
phone:String
});
我在控制器中查询:
Model
.find({ $text : { $search : "mo"} })
.exec(function(err, results) {
if(err){
console.log("eroro ocured");
res.send(401);
}else{
console.log("foud");
res.json(results);
}
});
它总是显示我的错误。
我想搜索的用户ID,我已经指定索引:在架构 –
真@MohammedGadiwala,尝试使用'thSchema2.index({'userid':'text'});','index:true'与文本索引不同。 – zangw
@MohammedGadiwala,这里有一个关于猫鼬的文本索引的讨论,https://github.com/Automattic/mongoose/issues/1401 – zangw