Experiment with MongoDB 2.4 on MongoLab!

Hello to all our friends and users!

We’re happy to announce that free, experimental databases running MongoDB 2.4 are now available at MongoLab! To get started quickly, follow our step-by-step guide.

Please note: This release is not ready for production yet and should not be used for any production applications.

Release Highlights

Here are the exciting new features and improvements in MongoDB 2.4 that we’d like to highlight:

Full-text search

For your exploration, we are boldly ignoring the warning label on this feature, which is described as an “experimental feature” in 2.4, and are running these servers with textSearchEnabled=true.

You get one text index per collection and create it, similarly to spatial indexes, by providing a special value in your index creation call.

The following simple example text-indexes the “skills” field of the “players” collection.

> db.players.ensureIndex({"skills": "text"})

You can include more than one text-indexed field in a single text index as well as other fields, such as:

> db.players.ensureIndex({"skills": "text", "interests": "text", "age": 1})

To run a query that returns documents that contain the word “telepathy” (case-insensitive) in either the skills or interests fields:

> db.players.runCommand("text", {"search": "telepathy"})

There are several considerations when making a text index and even useful options such as weighting of fields. So… before you make use of this feature, be sure to read the text indexes documentation.

The above example uses the mongo shell. If you want to run through this example in MongoLab’s admin UI, scroll on down…

JavaScript engine now uses v8 as the default

The default JavaScript interpreter used throughout MongoDB, for the mongo shell, mapreduce, $where and eval is now v8 instead of SpiderMonkey. For all users making use of the JavaScript engine, we encourage you to run the same code against this new engine and see how it performs!

Better GeoSpatial indexing

Spherical Geospatial queries are now supported by their own index type. You can create this new type of index just like you currently create a geospatial index, except that you need to specify “2dsphere” in the index definition instead of “2d”. Much like the 2d index requirement of storing [long, lat] data in a certain format, 2dsphere indexes have specific data considerations; for example, you must store a point, line, or polygon in GeoJSON format.

This new index type becomes even more useful with the $geoIntersects operator. Now, MongoDB can tell you if two of your shapes overlap. This is a powerful but specialized tool, so familiarize yourself with the details by reading the release notes and make sure it’s right for you.

An interrupted index build can now be resumed

Ah – this feature improvement is music to our ops-centric ears!  Previously if your mongod process died (either through intentional shutdown or unexpected termination) while you were building an index, you had to start the index build from scratch again.  As of this release, mongod will continue where it left off on an index build after the process starts again.

Example: A simple full-text search using MongoLab

Below is a step-by-step guide to creating a free database running MongoDB 2.4 and running your first full-text search.

[1] Sign up for a MongoLab account if you don’t already have one

[2] Click the “Create new” button after you are logged in to create the database, checking the highlighted checkbox below.  Note that database names need to be unique within an account and mongod process.
Screen Shot 2013-02-07 at 12.44.48 PM

[3] On the “Collections” tab click “Add” and create a collection called “players”

[4] We need some data to run a search against, so click into the row representing this collection so that we can add some.

[5] Click “Add” and copy the following document into the JSON editor:

     { "skills": "telepathy archery",
       "interests": "eating drinking",
       "age": 34 }

[6] On the “Indexes” tab click “Add” to text-index the “skills” and “interests” fields

Screen Shot 2013-02-08 at 12.42.25 PM

[7] Let’s run our first full-text search! On the “Tools” tab and the “commands” sub-tab, select the “text” command:

Screen Shot 2013-02-08 at 12.37.08 PM

Questions or Thoughts?

As you play around with our experimental databases running this new release, please email us anytime! We are eager to help you as you explore this exciting release or if you have any other questions or thoughts about MongoDB.

Subscribe

Subscribe to our e-mail newsletter to receive updates.