mirror of
https://github.com/mongodb/mongo.git
synced 2024-11-30 09:06:21 +01:00
shell should use the db's reIndex command
This commit is contained in:
parent
8f21c738c1
commit
b8f779a2a2
@ -495,7 +495,9 @@ namespace mongo {
|
||||
/* assuming here that id index is not multikey: */
|
||||
d->multiKeyIndexBits = 0;
|
||||
assureSysIndexesEmptied(ns, idIndex);
|
||||
anObjBuilder.append("msg", "non-_id indexes dropped for collection");
|
||||
anObjBuilder.append("msg", mayDeleteIdIndex ?
|
||||
"indexes dropped for collection" :
|
||||
"non-_id indexes dropped for collection");
|
||||
}
|
||||
else {
|
||||
// delete just one index
|
||||
|
@ -730,9 +730,12 @@ namespace mongo {
|
||||
/* unindex all keys in all indexes for this record. */
|
||||
static void unindexRecord(NamespaceDetails *d, Record *todelete, const DiskLoc& dl, bool noWarn = false) {
|
||||
BSONObj obj(todelete);
|
||||
int n = d->nIndexesBeingBuilt();
|
||||
for ( int i = 0; i < n; i++ ) {
|
||||
int n = d->nIndexes;
|
||||
for ( int i = 0; i < n; i++ )
|
||||
_unindexRecord(d->idx(i), obj, dl, !noWarn);
|
||||
if( d->backgroundIndexBuildInProgress ) {
|
||||
// always pass nowarn here, as this one may be missing for valid reasons as we are concurrently building it
|
||||
_unindexRecord(d->idx(n), obj, dl, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,39 +24,40 @@ DBCollection.prototype.verify = function(){
|
||||
|
||||
DBCollection.prototype.getName = function(){
|
||||
return this._shortName;
|
||||
}
|
||||
|
||||
DBCollection.prototype.help = function(){
|
||||
print("DBCollection help");
|
||||
print("\tdb.foo.count()");
|
||||
print("\tdb.foo.dataSize()");
|
||||
print("\tdb.foo.distinct( key ) - eg. db.foo.distinct( 'x' )" );
|
||||
print("\tdb.foo.drop() drop the collection");
|
||||
print("\tdb.foo.dropIndex(name)");
|
||||
print("\tdb.foo.dropIndexes()");
|
||||
print("\tdb.foo.ensureIndex(keypattern,options) - options should be an object with these possible fields: name, unique, dropDups");
|
||||
print("\tdb.foo.find( [query] , [fields]) - first parameter is an optional query filter. second parameter is optional set of fields to return.");
|
||||
print("\t e.g. db.foo.find( { x : 77 } , { name : 1 , x : 1 } )");
|
||||
print("\tdb.foo.find(...).count()");
|
||||
print("\tdb.foo.find(...).limit(n)");
|
||||
print("\tdb.foo.find(...).skip(n)");
|
||||
print("\tdb.foo.find(...).sort(...)");
|
||||
print("\tdb.foo.findOne([query])");
|
||||
print("\tdb.foo.findAndModify( { update : ... , remove : bool [, query: {}, sort: {}, 'new': false] } )");
|
||||
print("\tdb.foo.getDB() get DB object associated with collection");
|
||||
print("\tdb.foo.getIndexes()");
|
||||
print("\tdb.foo.group( { key : ..., initial: ..., reduce : ...[, cond: ...] } )");
|
||||
print("\tdb.foo.mapReduce( mapFunction , reduceFunction , <optional params> )" );
|
||||
print("\tdb.foo.remove(query)" );
|
||||
print("\tdb.foo.renameCollection( newName , <dropTarget> ) renames the collection.");
|
||||
print("\tdb.foo.save(obj)");
|
||||
print("\tdb.foo.stats()");
|
||||
print("\tdb.foo.storageSize() - includes free space allocated to this collection");
|
||||
print("\tdb.foo.totalIndexSize() - size in bytes of all the indexes");
|
||||
print("\tdb.foo.totalSize() - storage allocated for all data and indexes");
|
||||
print("\tdb.foo.update(query, object[, upsert_bool, multi_bool])");
|
||||
print("\tdb.foo.validate() - SLOW");
|
||||
print("\tdb.foo.getShardVersion() - only for use with sharding" );
|
||||
}
|
||||
|
||||
DBCollection.prototype.help = function() {
|
||||
print("DBCollection help");
|
||||
print("\tdb.foo.count()");
|
||||
print("\tdb.foo.dataSize()");
|
||||
print("\tdb.foo.distinct( key ) - eg. db.foo.distinct( 'x' )");
|
||||
print("\tdb.foo.drop() drop the collection");
|
||||
print("\tdb.foo.dropIndex(name)");
|
||||
print("\tdb.foo.dropIndexes()");
|
||||
print("\tdb.foo.ensureIndex(keypattern,options) - options should be an object with these possible fields: name, unique, dropDups");
|
||||
print("\tdb.foo.reIndex()");
|
||||
print("\tdb.foo.find( [query] , [fields]) - first parameter is an optional query filter. second parameter is optional set of fields to return.");
|
||||
print("\t e.g. db.foo.find( { x : 77 } , { name : 1 , x : 1 } )");
|
||||
print("\tdb.foo.find(...).count()");
|
||||
print("\tdb.foo.find(...).limit(n)");
|
||||
print("\tdb.foo.find(...).skip(n)");
|
||||
print("\tdb.foo.find(...).sort(...)");
|
||||
print("\tdb.foo.findOne([query])");
|
||||
print("\tdb.foo.findAndModify( { update : ... , remove : bool [, query: {}, sort: {}, 'new': false] } )");
|
||||
print("\tdb.foo.getDB() get DB object associated with collection");
|
||||
print("\tdb.foo.getIndexes()");
|
||||
print("\tdb.foo.group( { key : ..., initial: ..., reduce : ...[, cond: ...] } )");
|
||||
print("\tdb.foo.mapReduce( mapFunction , reduceFunction , <optional params> )");
|
||||
print("\tdb.foo.remove(query)");
|
||||
print("\tdb.foo.renameCollection( newName , <dropTarget> ) renames the collection.");
|
||||
print("\tdb.foo.save(obj)");
|
||||
print("\tdb.foo.stats()");
|
||||
print("\tdb.foo.storageSize() - includes free space allocated to this collection");
|
||||
print("\tdb.foo.totalIndexSize() - size in bytes of all the indexes");
|
||||
print("\tdb.foo.totalSize() - storage allocated for all data and indexes");
|
||||
print("\tdb.foo.update(query, object[, upsert_bool, multi_bool])");
|
||||
print("\tdb.foo.validate() - SLOW");
|
||||
print("\tdb.foo.getShardVersion() - only for use with sharding");
|
||||
}
|
||||
|
||||
DBCollection.prototype.getFullName = function(){
|
||||
@ -281,14 +282,10 @@ DBCollection.prototype.ensureIndex = function( keys , options ){
|
||||
|
||||
DBCollection.prototype.resetIndexCache = function(){
|
||||
this._indexCache = {};
|
||||
}
|
||||
|
||||
DBCollection.prototype.reIndex = function(){
|
||||
var specs = this.getIndexSpecs();
|
||||
this.dropIndexes();
|
||||
for ( var i = 0; i < specs.length; ++i ){
|
||||
this.ensureIndex( specs[i].key, [ specs[i].unique, specs[i].name ] );
|
||||
}
|
||||
}
|
||||
|
||||
DBCollection.prototype.reIndex = function() {
|
||||
return this._db.runCommand({ reIndex: this.getName() });
|
||||
}
|
||||
|
||||
DBCollection.prototype.dropIndexes = function(){
|
||||
|
Loading…
Reference in New Issue
Block a user