i have a problem with index in mongoose My model
var mongoose = require("mongoose"); var Schema = mongoose.Schema; var commentSchema = new Schema({ customer_id: String, motel_id: String, customer_name: String, content: String, created_at: Date }); commentSchema.set('autoIndex', false); commentSchema.index( {'$**': 'text'} ) var comments = mongoose.model("comments", commentSchema);
and my search function
function testIndex(req, res) { var searchString = "h"; comment.find({$text: {$search: searchString}}) .skip(20) .limit(10) .exec(function(err, docs) { res.send("docs:" + docs); }); }
but it don't return any value. How can i fix this problem?
请参考此链接 [1]: 在MongoDB和Mongoose中执行全文搜索的最佳方法在 enter code here
h-in-mongodb-and-mongoose
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.