I'm using mongo with node js & want to get the data for full-text search. But currently getting an empty array []
in return.
My API request is as follows -
router.post('/products/search', function(req, res, next) {
var search=req.body.search;
console.log(search)
Product.find({$text:{$search:search}},function(err,data)
{
console.log(data)
res.send(data)
});
});
And the database code is as follows -
var ProductSchema = new Schema({
category: String,
name: String,
price: Number,
cover: String,
search:String
})
Please help me to get the data.