Skip to content

Node.js based forum software built for the modern web

added indices on search key and id for mongo

barisusaklif81acd37dbfa
diff --git a/src/database/mongo.js b/src/database/mongo.js
index affb658dba..755a42c505 100644
--- a/src/database/mongo.js
+++ b/src/database/mongo.js
@@ -105,6 +105,12 @@
}
});
+ db.collection('search').ensureIndex({key: 1, id: 1}, {background: true}, function(err) {
+ if(err) {
+ winston.error('Error creating index ' + err.message);
+ }
+ });
+
if(typeof callback === 'function') {
callback();
}
diff --git a/src/database/mongo/main.js b/src/database/mongo/main.js
index 3c24830ffa..dacce8d9f6 100644
--- a/src/database/mongo/main.js
+++ b/src/database/mongo/main.js
@@ -13,7 +13,7 @@ module.exports = function(db, module) {
content: content
};
- db.collection('search').update({id:id, key:key}, {$set:data}, {upsert:true, w: 1}, function(err) {
+ db.collection('search').update({key:key, id:id}, {$set:data}, {upsert:true, w: 1}, function(err) {
if(err) {
winston.error('Error indexing ' + err.message);
}
@@ -41,7 +41,7 @@ module.exports = function(db, module) {
module.searchRemove = function(key, id, callback) {
callback = callback || helpers.noop;
- db.collection('search').remove({id:id, key:key}, callback);
+ db.collection('search').remove({key:key, id:id}, callback);
};
module.flushdb = function(callback) {