我正在使用nodejs Express服务器和mongojs,我想用Regex表达式在同一时间搜索所有字段。
我创建了一个像这样的索引:
myCollection.createIndex({'$**':'text'});
这是我的“查找”请求:
myCollection.find({$text:{$search:new RegExp('mySearchString')}}).limit(10, function(err, response) {
if (err) console.log(err);
});
我收到了错误:
{"name":"MongoError","message":"\"$search\" had the wrong type. Expected String, found RegEx","waitedMS":0,"ok":0,"errmsg":"\"$search\" had the wrong type. Expected String, found RegEx","code":14}
任何人都可以帮助我?
感谢。