DarkMatter in Cyberspace
  • Home
  • Categories
  • Tags
  • Archives

Full Text Search for Meteor App


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:

Getting Started with MongoDB

Text Search Tutorials of MongoDB 2.6.7;

$text query operator of MongoDB 2.6.7

Checking if a field contains a string



Published

Feb 1, 2015

Last Updated

Feb 1, 2015

Category

Tech

Tags

  • meteor 47
  • text search 1

Contact

  • Powered by Pelican. Theme: Elegant by Talha Mansoor