Skip to content

Instantly share code, notes, and snippets.

@cristopher-rodrigues
Last active December 14, 2015 12:44
Show Gist options
  • Save cristopher-rodrigues/ed97f981c5650fe18d83 to your computer and use it in GitHub Desktop.
Save cristopher-rodrigues/ed97f981c5650fe18d83 to your computer and use it in GitHub Desktop.
mongo index text search
//For a specified field
db.collectionname.createIndex(
{ "field_name": "text" },
{ name: "TextIndex" }
)
//For All Fields
db.collectionname.createIndex(
{ "$**": "text" },
{ name: "TextIndex" }
)
db.collectioname.find({$text: { $search: mathQ }});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment