From ff7573c65af86445e64eea657baeed6720e4d238 Mon Sep 17 00:00:00 2001 From: Eliot Horowitz Date: Mon, 2 Feb 2009 09:28:43 -0500 Subject: [PATCH] option for creating an index before or ater import --- tools/importJSON.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/importJSON.cpp b/tools/importJSON.cpp index d9b3e171cf6..dff49a890bd 100644 --- a/tools/importJSON.cpp +++ b/tools/importJSON.cpp @@ -36,6 +36,8 @@ public: ImportJSON() : Tool( "importjson" ){ add_options() ("file",po::value() , "file to import from" ) + ("idbefore", "create id index before importing " ) + ("id", "create id index after importing (reccomended) " ) ("drop", "drop collection first " ) ; addPositionArg( "file" , 1 ); @@ -64,6 +66,10 @@ public: _conn.dropCollection( ns.c_str() ); } + if ( hasParam( "idbefore" ) ){ + _conn.ensureIndex( ns.c_str() , BSON( "_id" << 1 ) ); + } + int num = 0; time_t start = time(0); @@ -94,6 +100,10 @@ public: } } + if ( hasParam( "id" ) ){ + _conn.ensureIndex( ns.c_str() , BSON( "_id" << 1 ) ); + } + return 0; } };