Created
March 20, 2015 19:43
-
-
Save josephmosby/50bb528c2833757e18c3 to your computer and use it in GitHub Desktop.
Index everything in a MongoDB collection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.system.js.save( | |
{ | |
_id: "indexAll", | |
value: function() { | |
colls = db.getCollectionNames(); | |
for (var i = 0; i < colls.length; i++) { | |
if (colls[i] != "system.indexes") { | |
db[colls[i]].createIndex( {"$**":"text"}, {name: "TextIndex"}); | |
} | |
} | |
} | |
} | |
) | |
// invoke with: | |
// db.loadServerScripts(); | |
// indexAll(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment