0
我似乎无法找到我错了什么。全文搜索的猫鼬索引
如果有人能指点正确的方向,那将是巨大的:
我的架构:
var postSchema = new Schema({
postID: String,
title: String
});
mongoose.model('post', postSchema, 'posts');
postSchema.index({title: 'text'});
这是为什么不工作:
apiRouter.get('/api/searchPosts', function(req, res, next){
postModel.find(
{ $text : { $search : req.query.text } }
)
.exec(function(err, posts) {
if(posts){
console.log('The query param is: ' + req.query.text);
console.log('The posts results is: ' + JSON.stringify(posts));
res.json({
posts : posts
});
} else {
res.send('Post does not exist');
}
});
});
结果我得到是:
查询参数是:Shayan
的帖子结果是:[]
Post表的标题字段中有结果“砂眼”为什么不是这方面的工作?
任何输入都会有所帮助。一如既往感谢
Shayan