How to do full text search in MongoDB

March 27, 2011 in Web Development

MySQL has had a pretty decent full text search engine in it’s MyISAM storage engine and for some developers it’s probably still a pretty big reason for sticking with MySQL (for some functionality at least).

Somebody published this link to the The MongoDB blog on Hacker News, just now, so I wanted to share it here. The article is actually from 2009 but it explains how to go about creating a full text search using Mongo. Even though this is a very simple example, it might help some people who rely on MySQL for some basic functionality.

However, like the author points out, it doesn’t have features like text stemming, ranking of queries matching n number of terms, bulk index building. More over it doesn’t do what MySQL does so well for foreign character sets: match words like ísland and island as the same (a big *win* feature of MySQL in my books)

But it would be interesting if somebody would implement that, even though just for fun. Maybe I should, but I’m not really in the mood atm.

Check out the full article: Full Text Search in Mongo – MongoDB.

  • http://pulse.yahoo.com/_WFAQYE63JLZXDRQH2KEZOLDJ5M Skall

    Previous versions of MongoDB (<= 1.8.0) doesn't support fulltext search at all. But MongoDB version 2.0+ supports excellent fulltext search via an plugin MongoLantern. Though it's a pretty new software but performs very good in terms of search result.