Skip to content

Instantly share code, notes, and snippets.

@madhavan-rp
Last active December 21, 2015 19:48
Show Gist options
  • Save madhavan-rp/6356449 to your computer and use it in GitHub Desktop.
Save madhavan-rp/6356449 to your computer and use it in GitHub Desktop.
Mongo Shell Commands Quick Reference
//Import
mongoimport --db myDB --collection myCollection --file myJSONFile.json
//Export
mongoexport --db myDB --collection myCollection --out myJSONFile.json
//Starting mongod with text search enabled
mongod --setParameter textSearchEnabled=true
//enable text search after starting normally
db.adminCommand( { setParameter : 1, textSearchEnabled : true } )
//Text Search on all fields
db.collection.ensureIndex({ "$**": "text" },{ name: "TextIndex" })
//Search a collection
db.collection.runCommand("text",{search:"where is the party?"})
//Remove all indexes
db.collection.dropIndexes()
//Update multiple documents
db.collection.update({'name' : 'Maddy'},{$set:{'awesomeness':'High'}},{upsert:false, multi:true})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment