use the new $text query from mongo 2.6

v1.18.x
barisusakli 11 years ago
parent ef8bbdd359
commit d00740703b

@ -22,17 +22,17 @@ module.exports = function(db, module) {
}; };
module.search = function(key, term, limit, callback) { module.search = function(key, term, limit, callback) {
db.command({text:'search' , search: term, filter: {key:key}, limit: limit }, function(err, result) { db.collection('search').find({ $text: { $search: term }, key: key}, {limit: limit}).toArray(function(err, results) {
if(err) { if(err) {
return callback(err); return callback(err);
} }
if(!result || !result.results || !result.results.length) { if(!results || !results.length) {
return callback(null, []); return callback(null, []);
} }
var data = result.results.map(function(item) { var data = results.map(function(item) {
return item.obj.id; return item.id;
}); });
callback(null, data); callback(null, data);

Loading…
Cancel
Save