MongoDB and Ruby

#MongoDB #Ruby

I gave a lightning talk on the Ruby driver for MongoDB at the Cloud Developer Camp in Düsseldorf on last Saturday. Here are the slides:

Tobias Trelle

MongoDB 2.4 Introduces Geospatial Indexing and Search for GeoJSON Geometries Point, LineString and Polygon

In case you are unfamiliar with the geospatial stuff, have a look at this introduction to geospatial indexing and searching with MongoDB.

In version 2.4 MongoDB introduces support for a subset of GeoJSON geometries. These geometries can be used both as data and query expressions.


GeoJSON is a specification for describing geometrical shapes with the help of the JSON (JavaScript Object Notation) format. The basic shapes are points, line strings, polygons and compositions of these shapes. Here are some examples:

// a Point object
{ type: "Point", coordinates: [0.5, 0.5] }
// a LineString object
{ type: "LineString", coordinates: [ [100.0, 0.0], [101.0, 1.0] ] }
// a simple Polygon object, a box
{ "type": "Polygon",
  "coordinates": [
    [ [0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [0.0, 1.0], [0.0, 0.0] ]

GeoJSON Support in MongoDB

Prior to version 2.4 geospatial data in MongoDB was solely points. You were able to index points denoted by a two-dimensional array ( [1,2] ) or an embedded document with two fields ( {x:1, y:2} ). By using GeoJSON geometries you …
(read more…)

Tobias Trelle

MongoDB Text Search Tutorial

In my introduction to text search in MongoDB, we had a look at the basic features. Today we’ll have a closer look at the details.


You may have noticed that a text search is not executed with a find() command. Instead you call "text", {search: "bar"} )

Remember it’s an experimental feature still. Adding it to the implementation of the find() command would have mixed critical production code with the new text search feature. When executed via a runCommand() call, text search can be run and tested in isolation.

I expect to see a new query operator like $text or $textsearch as soon as text search is integrated with the standard find() command.

Text Query Syntax

In the previous examples we just searched for a single word. We can do more than that. Let’s have a look at the following example: {txt: "text"} ) {txt: "Robots are superior to humans"} ) {txt: "Humans are weak"} ) {txt: "I, Robot - by Isaac Asimov"} )

(read more…)

Tobias Trelle