diff --git a/src/database/mongo/main.js b/src/database/mongo/main.js index 144f80693b..22155ff6d2 100644 --- a/src/database/mongo/main.js +++ b/src/database/mongo/main.js @@ -22,17 +22,17 @@ module.exports = function(db, module) { }; 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) { return callback(err); } - if(!result || !result.results || !result.results.length) { + if(!results || !results.length) { return callback(null, []); } - var data = result.results.map(function(item) { - return item.obj.id; + var data = results.map(function(item) { + return item.id; }); callback(null, data);