From c245e7066cbc6b7e31505faaea0491c467405329 Mon Sep 17 00:00:00 2001 From: Eliot Horowitz Date: Mon, 9 Feb 2009 13:05:36 -0500 Subject: [PATCH] reIndex --- shell/collection.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/shell/collection.js b/shell/collection.js index e81cc205b9306..201552c978a80 100644 --- a/shell/collection.js +++ b/shell/collection.js @@ -162,7 +162,15 @@ DBCollection.prototype.resetIndexCache = function(){ this._indexCache = {}; } -DBCollection.prototype.dropIndexes = function() { +DBCollection.prototype.reIndex = function(){ + var keys = this.getIndexKeys(); + this.dropIndexes(); + for ( var i in keys ){ + this.ensureIndex( keys[i] ); + } +} + +DBCollection.prototype.dropIndexes = function(){ this.resetIndexCache(); var res = this._db.runCommand( { deleteIndexes: this.getName(), index: "*" } );