Skip to content

Instantly share code, notes, and snippets.

@romuloctba
Forked from cristopher-rodrigues/index.js
Created December 14, 2015 12:44
Show Gist options
  • Save romuloctba/2e311a36be0676493224 to your computer and use it in GitHub Desktop.
Save romuloctba/2e311a36be0676493224 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