SlideShare a Scribd company logo
MapReduce,  Geospatial  Indexes,  
   and  Other  Cool  Features



         Kristina  Chodorow
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
connecting  to  
    your  mongod
connecting  to  
    your  mongod


           you
connecting  to  
    your  mongod


           you


                 mongod
mongod
mongod
update   insert query insert   query   mongod
mongod



driver
query


    insert


   driver
insert




           query   mongod



driver
insert
getlasterror




                   mongod



          driver
insert
         getlasterror
                        mongod



driver
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
replication
 Dwight  @  3:15
 Farallon Room
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
insert  this
all  set
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
insert  this
all  set
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
make  sure  two  
slaves  have  this
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
all  set
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
make  sure  two  
slaves  have  this
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
>  db.runCommand({
...  getlasterror :  1
...  })
>  db.runCommand({
...  getlasterror :  1,
...  w  :  3
...  })
>  db.runCommand({
...  getlasterror :  1,
...  w  :  500
...  })
>  db.runCommand({
...  getlasterror :  1,
...  w  :  500,
...  wtimeout :  3000
...  })
>  db.runCommand({
...  getlasterror :  1,
...  fsync :  true
...  })
some  internals
Operations:
      insert
      update
      remove
      query
      get  more
Operations:
      insert
      update
      remove
      query
      get  more
Operations:
      insert
      update
      remove
      query
      get  more
Operations:
      insert
      update
      remove
      query
      get  more
Operations:
      insert
      update
      remove
      query
      get  more
Operations:
      insert
      update
      remove
      query
      get  more
Operations:
      insert
      update
      remove
      query
      get  more
get  help
$  mongo
MongoDB  shell  version  1.5.1
url:  test
connecting  to:  test
type  "help"  for  help
>
$  mongo
MongoDB  shell  version  1.5.1
url:  test
connecting  to:  test
type  "help"  for  help
>
>  db.help()
DB  methods:
      db.addUser()
      db.auth()
      db.cloneDatabase()
      db.commandHelp()
      db.copyDatabase()
      db.createCollection()
      db.currentOp()
      ...
>  db.foo.help()
DBCollection help
      db.foo.count()
      db.foo.dataSize()
      db.foo.distinct()
      db.foo.drop()
      db.foo.dropIndex()
      db.foo.dropIndexes()
      ...
>  var cursor  =  db.foo.find()
>  cursor.help()
DBQuery help
      .sort()
      .limit()
      .skip()
      .count()
      .size()
      ...
http://api.mongodb.org/js
>  db.foo.count()
40
>
>  db.foo.count()
40
>  db.foo.count
>  db.foo.count()
40
>  db.foo.count
function(x)  {
   return  this.find(x).count();;
}
>
>  db.foo.count()
40
>  db.foo.count
function(x)  {
   return  this.find(x).count();;
}
>  var cursor  =  db.foo.find()
>
>  db.foo.count()
40
>  db.foo.count
function(x)  {
   return  this.find(x).count();;
}
>  var cursor  =  db.foo.find()
>  cursor.count
>  cursor.count
function(applySkipLimit)  {
   var cmd =  {count  :  this._collection.getName()};;
   if  (this._query)  {
     if  (this._special)  {
        cmd.query =  this._query.query;;
     }
     else  {
        cmd.query =  this._query;;
     }
   }
   cmd.fields =  this._fields ||  {};;
   if  (applySkipLimit)  {
     if  (this._limit)  {
        cmd.limit =  this._limit;;
...
function(x)  {
  //  prep  cmd
  ...

    //  run  command
    var res  =  this._db.runCommand(cmd);;

    //  return  result
    ...
}
>  db.runCommand({count  :  "foo"})
{
     "n"  :  40,
     "ok"  :  1
}
>
>  db.runCommand({listCommands :  1})
>  db.runCommand({listCommands :  1})
{
   "commands"  :  {
     "$eval"  :  {...},
     "assertinfo :  {...},
     "authenticate"  :  {...},
     "buildinfo"  :  {...},
     "clean"  :  {...},
     "clone"  :  {...},
     "cloneCollection"  :  {...},
     "cloneCollectionAsCapped"  :  {...},
     "closeAllDatabases"  :  {...},
     ...
>  db.runCommand({
...  datasize :  collectionName})
>  db.runCommand({
...  datasize :  collectionName})


>  db.runCommand({
...  dbstats :  1})
>  db.commandHelp("distinct")
help  for:  distinct:  {  
   distinct  :  'collection  name',
   key  :  'a.b'  }
>
>  db.commandHelp("distinct")
help  for:  distinct:  {  
   distinct  :  'collection  name',
   key  :  'a.b'  }
>  db.commandHelp
function(name)  {
   var c  =  {};;
   c[name]  =  1;;
   c.help =  true;;
   return  this.runCommand(c).help;;
}
>
>  db.runCommand({"count"  :  1,  
...  "help"  :  true})
>  db.runCommand({"count"  :  1,  
...  "help"  :  true})
help  for:  count:  no  help  defined
>
$
>  db.blog.posts.find(
...  {_id  :  123},
...  {comments  :  1})
>  db.blog.posts.find(
...  {_id  :  123},
...  {comments  :  {$slice  :  10}})
>  db.blog.posts.find(
...  {_id  :  123},
...  {comments  :  {$slice  :  [20,  10]}})
>  db.blog.posts.find(
...  {_id  :  123},
...  {comments  :  {$slice  :  -­10}})
>  db.blog.posts.find(
...  {_id  :  123},
...  {comments  :  {$slice  :  [-­20,  10]}})
>  db.blog.posts.find({
...  comments  :  {
...      date  :  {$gt :  today},
...      votes  :  {$gte :  10}
...  }})
>  db.blog.posts.find({
...  'comments.date'  :  {$gt :  today},
...  'comments.votes'  :  {$gte :  10}
...  })
>  db.blog.posts.find({
...  comments  :  {$elemMatch :  {
...      date  :  {$gt :  today},
...      votes  :  {$gte :  10}
...  }}})
Types
minKey




         maxKey
MapReduce
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
{
    _id  :  123,
    name  :  "Fred",
    email  :  "fred@example.com"
}

{
    _id  :  456,
    name  :  "Paul",
    phone  :  "555-­5555",
    picture  :  BinData
}


{
    _id  :  789,
    email  :  "alice@example.com",
}
_id                 40
name                32
email               20
phone               2
picture             17
pet                 3
friends             40
hobbies             6
favorites           12
notes               14
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
{
    _id  :  123,
    name  :  "Fred",
    email  :  "fred@example.com"
}
1
    1
        1
_id
            1




            name
       1




    email
1
email
email
12
cluck  cluck




               12
email

        12
map  =  function()  {
  for  (var key  in  this)  {
     emit(key,  1);;
  }
}
reduce  =  function(prev,  current)  {
  var count  =  0;;
  for  (var egg  in  current)  {
    count  +=  current[egg];;
  }
  return  count;;
}
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
A   B   C   D   E   F
A   B   C   D   E   F
A                 B           C                D              E              F




_id  :  A,  value  :              _id  :  C,  value  :               _id  :  E,  value  :


                  _id  :  B,  value  :                   _id  :  D,  value  :               _id  :  F,  value  :
GridFS
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
Indexes
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
>  db.users.find({
...  date  :  new  Date("10/3/2010")})




>  db.users.ensureIndex({
...  date  :  1})
Dates,  timestamps,  ObjectIds
indexing
Aaron  @  3:15
Niantic  Room
Geospatial  Indexes
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
>  db.map.ensureIndex({location  :  "2d"})
>
>  db.map.insert({location  :  [-­40,  78]})
>
>  db.map.insert({location  :  [-­40,  78]})
>  db.map.insert({location  :  {
...  x  :  -­40,  
...  y  :  78}})
>
>  db.map.insert({location  :  [-­40,  78]})
>  db.map.insert({location  :  {
...  x  :  -­40,  
...  y  :  78}})
>  db.map.insert({location  :  {
...  longitude  :  -­40,  
...  latitude  :  78}})
>
>  db.map.find({location  :  {
...  $near  :  [-­40,  77]}})
>  db.map.find({location  :  {
...  $near  :  [-­40,  77]}})-­>limit(10)
>  db.map.ensureIndex({
...  location  :  "2d",
...  user  :  1});;
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
1  degree  of  longitude  at  the  equator:
1  degree  of  longitude  at  the  equator:




1  degree  of  longitude  near  the  poles:
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
geospatial
 Eliot  @  10:15
Gateway  Room
please  help  
  document  stuff!

http://cookbook.mongodb.org
want  to  work  on  
   mongodb?


http://www.10gen.com/jobs
thank  you!

          @kchodorow

http://www.snailinaturtleneck.com

More Related Content

PDF
Building Real Time Systems on MongoDB Using the Oplog at Stripe
PDF
MongoDB Oplog入門
PDF
MongoDBで作るソーシャルデータ新解析基盤
PPTX
Super Advanced Python –act1
PDF
MongoDB全機能解説2
PDF
Aggregation Pipeline Power++: MongoDB 4.2 파이프 라인 쿼리, 업데이트 및 구체화된 뷰 소개 [MongoDB]
PDF
Elm: give it a try
PDF
Nosql hands on handout 04
Building Real Time Systems on MongoDB Using the Oplog at Stripe
MongoDB Oplog入門
MongoDBで作るソーシャルデータ新解析基盤
Super Advanced Python –act1
MongoDB全機能解説2
Aggregation Pipeline Power++: MongoDB 4.2 파이프 라인 쿼리, 업데이트 및 구체화된 뷰 소개 [MongoDB]
Elm: give it a try
Nosql hands on handout 04

What's hot (20)

PDF
Cycle.js: Functional and Reactive
PDF
The Ring programming language version 1.5.4 book - Part 40 of 185
PDF
MySQL 5.7 NF – JSON Datatype 활용
PDF
MySQL flexible schema and JSON for Internet of Things
PDF
はじめてのGroovy
PDF
Rデバッグあれこれ
PDF
Rのスコープとフレームと環境と
PPTX
Kamil Chmielewski, Jacek Juraszek - "Hadoop. W poszukiwaniu złotego młotka."
PDF
Groovy collection api
PDF
20110514 mongo dbチューニング
PDF
Inside MongoDB: the Internals of an Open-Source Database
PDF
mobl - model-driven engineering lecture
PPTX
Ricky Bobby's World
PDF
MongoDB Performance Tuning
PDF
Pymongo for the Clueless
PDF
The Ring programming language version 1.7 book - Part 48 of 196
PDF
MongoDB .local Paris 2020: La puissance du Pipeline d'Agrégation de MongoDB
PDF
집단지성 프로그래밍 08-가격모델링
PPTX
Fact, Fiction, and FP
PDF
Google App Engine Developer - Day3
Cycle.js: Functional and Reactive
The Ring programming language version 1.5.4 book - Part 40 of 185
MySQL 5.7 NF – JSON Datatype 활용
MySQL flexible schema and JSON for Internet of Things
はじめてのGroovy
Rデバッグあれこれ
Rのスコープとフレームと環境と
Kamil Chmielewski, Jacek Juraszek - "Hadoop. W poszukiwaniu złotego młotka."
Groovy collection api
20110514 mongo dbチューニング
Inside MongoDB: the Internals of an Open-Source Database
mobl - model-driven engineering lecture
Ricky Bobby's World
MongoDB Performance Tuning
Pymongo for the Clueless
The Ring programming language version 1.7 book - Part 48 of 196
MongoDB .local Paris 2020: La puissance du Pipeline d'Agrégation de MongoDB
집단지성 프로그래밍 08-가격모델링
Fact, Fiction, and FP
Google App Engine Developer - Day3
Ad

Viewers also liked (8)

PPTX
MongoDB on EC2 and EBS
PPTX
Introduction to Cassandra (June 2010)
PDF
NoSQL databases
PPTX
Introducción a Machine Learning
PDF
NoSQL: Introducción a las Bases de Datos no estructuradas
PPTX
Conceptos básicos. Seminario web 1: Introducción a NoSQL
PPTX
Base de Datos Orientada a Objetos
PPTX
10 sistemas gestores de base de datos
MongoDB on EC2 and EBS
Introduction to Cassandra (June 2010)
NoSQL databases
Introducción a Machine Learning
NoSQL: Introducción a las Bases de Datos no estructuradas
Conceptos básicos. Seminario web 1: Introducción a NoSQL
Base de Datos Orientada a Objetos
10 sistemas gestores de base de datos
Ad

Similar to Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow) (20)

PDF
Latinoware
PDF
FrozenRails Training
PDF
Building Apps with MongoDB
PPT
Building Your First MongoDB App ~ Metadata Catalog
PPTX
Mongodb introduction and_internal(simple)
PDF
Mongo db
KEY
Seedhack MongoDB 2011
KEY
2012 phoenix mug
KEY
MongoDB - Introduction
PDF
mongodb-introduction
PPTX
MongoDB Live Hacking
PDF
10gen Presents Schema Design and Data Modeling
PPTX
MongoDB Chicago - MapReduce, Geospatial, & Other Cool Features
PDF
Advanced Analytics & Statistics with MongoDB
PDF
Quick overview on mongo db
PPTX
Webinar: General Technical Overview of MongoDB for Dev Teams
KEY
Schema Design with MongoDB
PPTX
Introduction tomongodb
PDF
2012-08-29 - NoSQL Bootcamp (Redis, RavenDB & MongoDB für .NET Entwickler)
PDF
2013-03-23 - NoSQL Spartakiade
Latinoware
FrozenRails Training
Building Apps with MongoDB
Building Your First MongoDB App ~ Metadata Catalog
Mongodb introduction and_internal(simple)
Mongo db
Seedhack MongoDB 2011
2012 phoenix mug
MongoDB - Introduction
mongodb-introduction
MongoDB Live Hacking
10gen Presents Schema Design and Data Modeling
MongoDB Chicago - MapReduce, Geospatial, & Other Cool Features
Advanced Analytics & Statistics with MongoDB
Quick overview on mongo db
Webinar: General Technical Overview of MongoDB for Dev Teams
Schema Design with MongoDB
Introduction tomongodb
2012-08-29 - NoSQL Bootcamp (Redis, RavenDB & MongoDB für .NET Entwickler)
2013-03-23 - NoSQL Spartakiade

More from MongoSF (20)

PPTX
Webinar: Typische MongoDB Anwendungsfälle (Common MongoDB Use Cases) 
PPTX
Schema design with MongoDB (Dwight Merriman)
KEY
C# Development (Sam Corder)
KEY
Flexible Event Tracking (Paul Gebheim)
KEY
Administration (Eliot Horowitz)
PDF
Ruby Development and MongoMapper (John Nunemaker)
PDF
MongoHQ (Jason McCay & Ben Wyrosdick)
KEY
Administration
KEY
Sharding with MongoDB (Eliot Horowitz)
KEY
Practical Ruby Projects (Alex Sharp)
PDF
Implementing MongoDB at Shutterfly (Kenny Gorman)
PDF
Debugging Ruby (Aman Gupta)
PPTX
Indexing and Query Optimizer (Aaron Staple)
PPTX
MongoDB Replication (Dwight Merriman)
PDF
Zero to Mongo in 60 Hours
KEY
Building a Mongo DSL in Scala at Hot Potato (Lincoln Hochberg)
KEY
PHP Development with MongoDB (Fitz Agard)
PPT
Java Development with MongoDB (James Williams)
PPTX
Real time ecommerce analytics with MongoDB at Gilt Groupe (Michael Bryzek & M...
PPTX
From MySQL to MongoDB at Wordnik (Tony Tam)
Webinar: Typische MongoDB Anwendungsfälle (Common MongoDB Use Cases) 
Schema design with MongoDB (Dwight Merriman)
C# Development (Sam Corder)
Flexible Event Tracking (Paul Gebheim)
Administration (Eliot Horowitz)
Ruby Development and MongoMapper (John Nunemaker)
MongoHQ (Jason McCay & Ben Wyrosdick)
Administration
Sharding with MongoDB (Eliot Horowitz)
Practical Ruby Projects (Alex Sharp)
Implementing MongoDB at Shutterfly (Kenny Gorman)
Debugging Ruby (Aman Gupta)
Indexing and Query Optimizer (Aaron Staple)
MongoDB Replication (Dwight Merriman)
Zero to Mongo in 60 Hours
Building a Mongo DSL in Scala at Hot Potato (Lincoln Hochberg)
PHP Development with MongoDB (Fitz Agard)
Java Development with MongoDB (James Williams)
Real time ecommerce analytics with MongoDB at Gilt Groupe (Michael Bryzek & M...
From MySQL to MongoDB at Wordnik (Tony Tam)

Recently uploaded (20)

PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Mushroom cultivation and it's methods.pdf
PPTX
Spectroscopy.pptx food analysis technology
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Approach and Philosophy of On baking technology
PPT
Teaching material agriculture food technology
PPTX
Machine Learning_overview_presentation.pptx
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
Machine learning based COVID-19 study performance prediction
PPTX
cloud_computing_Infrastucture_as_cloud_p
PDF
Empathic Computing: Creating Shared Understanding
Univ-Connecticut-ChatGPT-Presentaion.pdf
NewMind AI Weekly Chronicles - August'25-Week II
Network Security Unit 5.pdf for BCA BBA.
MIND Revenue Release Quarter 2 2025 Press Release
Mushroom cultivation and it's methods.pdf
Spectroscopy.pptx food analysis technology
A comparative analysis of optical character recognition models for extracting...
Spectral efficient network and resource selection model in 5G networks
Approach and Philosophy of On baking technology
Teaching material agriculture food technology
Machine Learning_overview_presentation.pptx
Programs and apps: productivity, graphics, security and other tools
A comparative study of natural language inference in Swahili using monolingua...
Reach Out and Touch Someone: Haptics and Empathic Computing
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Machine learning based COVID-19 study performance prediction
cloud_computing_Infrastucture_as_cloud_p
Empathic Computing: Creating Shared Understanding

Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)