For Meteor 1.0.3, the built-in database is mongodb 2.4, which is not support full text search by default. So we need install a stand-alone MongoDB 2.6, create a "meteor" database, and let Meteor to use it as backend database:
First start MongoDB server: mongod --dbpath ~/docs/mongodb-repo
;
Then create a new database "meteor" for Meteor app backend:
$ mongo
> show dbs
> use meteor
Next start Meteor server and connect it with the Mongodb server:
$ MONGO_URL="mongodb://localhost:27017/meteor" meteor
> db.zips.getIndexes()
> db.zips.dropIndex("forsearch_text")
> db.zips.ensureIndex( {city: "text", state: "text"} )
> db.zips.find( {$text: {$search: "lee ma"}} ).count()
488
Here use meteor
create a new database in MongoDB (if it doesn't exists yet)
and use it as the current database.
Use db
to get the current database name.
Ref:
Text Search Tutorials of MongoDB 2.6.7;
$text query operator of MongoDB 2.6.7
Checking if a field contains a string