SlideShare a Scribd company logo
1   #commands for adding spatial data!
 2   !
 3   #Take a look at the file first!
 4   less parkcoord.json!
 5   #get the file on the server!
 6   scp parkcoord.json 0b49d9219f2847c6a236820959f9a@parks-spmongo.rhcloud.com:parks/data/!
 7   !
 8   #ssh into the machine!
 9   ssh 0b49d9219f2847c6a236820959f9a@parks-spmongo.rhcloud.com!
10   !
11   #import into mongo!
12   mongoimport -d parks -c mongosf --type json --file parks/data/parkcoord.json -h $OPENSHIFT_NOSQL_DB_HOST -u admin -p <your
 …   password>!
13   !
14   #open the mongo shell!
15   mongo -u admin -p <your password> $OPENSHIFT_NOSQL_DB_HOST/parks!
16   !
17   #build the index!
18   db.mongosf.ensureIndex({"pos":"2d"});!
19   !
20   #Now some queries!
21   #simple spatial!
22   db.mongosf.find({"pos" : { "$near" : [-37, 41]}});!
23   !
24   #spatial and text query using regex!
25   db.mongosf.find( { Name : /lincoln/i, pos : { $near : [-37,41] }} );!
26   !
27   #geonear TODO!
28   db.runCommand({ geoNear : "mongosf", near : [-37,41], num : 10 });!
29   !
30   !
31   #create a new collection from scratch!
32   db.createCollection("mongosfuserloc");!
33   db.mongosfuserloc.ensureIndex( { pos : "2d" } );!
34   !
35   #insert a new record!
36   db.mongosfuserloc.insert({ "created" : new Date(), "Notes" : 'just landed', "pos" : [-76.7302 , 25.5332 ] })!
37   !   !
38   #quick query to make sure it worked!
39   db.mongosfuserloc.find( { pos : { $near : [-37,41] } } )!
40   !
41   #add a second document closer to query point!
42   #this is an upsert - since we don't pass in the _id it creates a new record!
43   db.mongosfuserloc.save({ created : new Date(), Notes: 'that was a big step', pos : [-37.7302 , 40.5332 ]});!
44   !
45   #one way to update original document!
46   myDoc = db.mongosfuserloc.findOne({_id : ObjectId("ID for the first object")});!
47   myDoc.Notes = "really the landing";!
48   db.mongosfuserloc.save(myDoc);!
49

More Related Content

What's hot (20)

PDF
Spatial script for my JS.Everywhere 2012
Steven Pousty
 
PPTX
Bringing Spatial Love to Your Java Application
MongoDB
 
PPTX
Back to Basics German 3: EinfĂźhrung in Replica Sets
MongoDB
 
PDF
faastCrystal
Sachirou Inoue
 
PDF
Introduction to Hadoop - FinistJug
David Morin
 
PPT
Installation of application server 10g in red hat 4
uzzzle
 
PDF
Ruby on embedded devices rug::b Aug 2014
Eno Thierbach
 
PPTX
Python Dependencies at Beeswax - BazelCon 2019 Lightning Talk - Ron Rothman
Ron Rothman
 
PDF
Redis clustering
Ravi Yasas
 
PDF
Infrastructure coders logstash
David Lutz
 
PDF
Cloud Firestore – From JSON Deserialization to Object Document Mapping (ODM)
Minh Dao
 
PDF
Datafying Bitcoins
Tariq Ahmad
 
PDF
Make the prompt great again
jtyr
 
PDF
Build, Ship, and Run Any App, Anywhere using Docker
Rahulkrishnan R A
 
PPTX
MessagePack - An efficient binary serialization format
Larry Nung
 
PDF
Kubernetes - Parte I
Denny Vriesman
 
PDF
Hadoop con2016 - Implement Real-time Centralized logging System by Elastic Stack
Len Chang
 
PPTX
How To Run Mapreduce Jobs In Python
Yi Wang
 
PDF
OSS AWS 핸즈온 강의
Juhong Jung
 
PDF
MongoDB 3.0.0 vs 2.6.x vs 2.4.x Benchmark
承翰 蔡
 
Spatial script for my JS.Everywhere 2012
Steven Pousty
 
Bringing Spatial Love to Your Java Application
MongoDB
 
Back to Basics German 3: EinfĂźhrung in Replica Sets
MongoDB
 
faastCrystal
Sachirou Inoue
 
Introduction to Hadoop - FinistJug
David Morin
 
Installation of application server 10g in red hat 4
uzzzle
 
Ruby on embedded devices rug::b Aug 2014
Eno Thierbach
 
Python Dependencies at Beeswax - BazelCon 2019 Lightning Talk - Ron Rothman
Ron Rothman
 
Redis clustering
Ravi Yasas
 
Infrastructure coders logstash
David Lutz
 
Cloud Firestore – From JSON Deserialization to Object Document Mapping (ODM)
Minh Dao
 
Datafying Bitcoins
Tariq Ahmad
 
Make the prompt great again
jtyr
 
Build, Ship, and Run Any App, Anywhere using Docker
Rahulkrishnan R A
 
MessagePack - An efficient binary serialization format
Larry Nung
 
Kubernetes - Parte I
Denny Vriesman
 
Hadoop con2016 - Implement Real-time Centralized logging System by Elastic Stack
Len Chang
 
How To Run Mapreduce Jobs In Python
Yi Wang
 
OSS AWS 핸즈온 강의
Juhong Jung
 
MongoDB 3.0.0 vs 2.6.x vs 2.4.x Benchmark
承翰 蔡
 

Viewers also liked (7)

PPT
Overview Study on PIC32MX3XX / 4XX 32-Bit Controller
Premier Farnell
 
PDF
Rio negro instructivo para presidentes_de_mesa_elecciones_14-06-2015
DirecciĂłn Nacional Electoral de Argentina
 
PPSX
Curso de alisado brasileĂąo
asunsol
 
PPTX
Monitor slideshow
fallbrookmedical
 
PPTX
Trabajo vanesaa beltran
vanessabeltran95
 
PDF
Np presentaciĂłn lotus exige gt
Dolcevitacoruna
 
PPSX
Proyecto final productos - sede chitre
isaepanama
 
Overview Study on PIC32MX3XX / 4XX 32-Bit Controller
Premier Farnell
 
Rio negro instructivo para presidentes_de_mesa_elecciones_14-06-2015
DirecciĂłn Nacional Electoral de Argentina
 
Curso de alisado brasileĂąo
asunsol
 
Monitor slideshow
fallbrookmedical
 
Trabajo vanesaa beltran
vanessabeltran95
 
Np presentaciĂłn lotus exige gt
Dolcevitacoruna
 
Proyecto final productos - sede chitre
isaepanama
 
Ad

Similar to MongoSF - Spatial MongoDB in OpenShift - script file (20)

PDF
Spatial script for Spatial mongo for PHP and Zend
Steven Pousty
 
PDF
Script for Spatial Mongo
Steven Pousty
 
PDF
Spatial script for CIMA
Steven Pousty
 
PPTX
Getting Started with Geospatial Data in MongoDB
MongoDB
 
PDF
MongoDB全機能解説2
Takahiro Inoue
 
ODT
Spatial script for MongoBoulder
Steven Pousty
 
PDF
Geospatial Enhancements in MongoDB 2.4
MongoDB
 
PPTX
MongoDB GeoSpatial Feature
HĂźseyin BABAL
 
KEY
Geospatial Indexing and Querying with MongoDB
Grant Goodale
 
PPTX
Open Source Mapping with Python, and MongoDB
techprane
 
PDF
Geospatial and MongoDB
Norberto Leite
 
PPTX
Conceptos bĂĄsicos. Seminario web 4: IndexaciĂłn avanzada, Ă­ndices de texto y g...
MongoDB
 
PPTX
Geoindexing with MongoDB
leafnode
 
PDF
OSDC 2012 | Building a first application on MongoDB by Ross Lawley
NETWAYS
 
PPT
Building web applications with mongo db presentation
Murat Çakal
 
KEY
Building Your First MongoDB Application
Rick Copeland
 
PPTX
Back to Basics Webinar 4: Advanced Indexing, Text and Geospatial Indexes
MongoDB
 
PDF
mongodb-introduction
Tse-Ching Ho
 
PDF
A Century Of Weather Data - Midwest.io
Randall Hunt
 
PPT
9b. Document-Oriented Databases lab
Fabio Fumarola
 
Spatial script for Spatial mongo for PHP and Zend
Steven Pousty
 
Script for Spatial Mongo
Steven Pousty
 
Spatial script for CIMA
Steven Pousty
 
Getting Started with Geospatial Data in MongoDB
MongoDB
 
MongoDB全機能解説2
Takahiro Inoue
 
Spatial script for MongoBoulder
Steven Pousty
 
Geospatial Enhancements in MongoDB 2.4
MongoDB
 
MongoDB GeoSpatial Feature
HĂźseyin BABAL
 
Geospatial Indexing and Querying with MongoDB
Grant Goodale
 
Open Source Mapping with Python, and MongoDB
techprane
 
Geospatial and MongoDB
Norberto Leite
 
Conceptos bĂĄsicos. Seminario web 4: IndexaciĂłn avanzada, Ă­ndices de texto y g...
MongoDB
 
Geoindexing with MongoDB
leafnode
 
OSDC 2012 | Building a first application on MongoDB by Ross Lawley
NETWAYS
 
Building web applications with mongo db presentation
Murat Çakal
 
Building Your First MongoDB Application
Rick Copeland
 
Back to Basics Webinar 4: Advanced Indexing, Text and Geospatial Indexes
MongoDB
 
mongodb-introduction
Tse-Ching Ho
 
A Century Of Weather Data - Midwest.io
Randall Hunt
 
9b. Document-Oriented Databases lab
Fabio Fumarola
 
Ad

More from Steven Pousty (12)

PPTX
APPLICATIONS AND CONTAINERS AT SCALE: OpenShift + Kubernetes + Docker
Steven Pousty
 
PDF
Introduction to PaaS for application developers
Steven Pousty
 
PDF
London Cloud Summit 2014 - raising the tide: getting developers in the cloud
Steven Pousty
 
PPT
Workshop For pycon13
Steven Pousty
 
ODP
Build a PaaS with OpenShift Origin
Steven Pousty
 
PPTX
Monkigras - dropping science on your developer ecosystem
Steven Pousty
 
PPTX
Dropping Science on Your Developer Ecosystem - lessons from Ecosystem Management
Steven Pousty
 
PDF
Open shift intro for Philly PUG
Steven Pousty
 
PPT
Open shift intro for Philly PUG
Steven Pousty
 
PPTX
deCarta at BAPI
Steven Pousty
 
PPT
LinuxFest NW - Using Postgis To Add Some Spatial Flavor To Your App
Steven Pousty
 
PPT
Using PostGIS To Add Some Spatial Flavor To Your Application
Steven Pousty
 
APPLICATIONS AND CONTAINERS AT SCALE: OpenShift + Kubernetes + Docker
Steven Pousty
 
Introduction to PaaS for application developers
Steven Pousty
 
London Cloud Summit 2014 - raising the tide: getting developers in the cloud
Steven Pousty
 
Workshop For pycon13
Steven Pousty
 
Build a PaaS with OpenShift Origin
Steven Pousty
 
Monkigras - dropping science on your developer ecosystem
Steven Pousty
 
Dropping Science on Your Developer Ecosystem - lessons from Ecosystem Management
Steven Pousty
 
Open shift intro for Philly PUG
Steven Pousty
 
Open shift intro for Philly PUG
Steven Pousty
 
deCarta at BAPI
Steven Pousty
 
LinuxFest NW - Using Postgis To Add Some Spatial Flavor To Your App
Steven Pousty
 
Using PostGIS To Add Some Spatial Flavor To Your Application
Steven Pousty
 

Recently uploaded (20)

PDF
🚀 Let’s Build Our First Slack Workflow! 🔧.pdf
SanjeetMishra29
 
PDF
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PDF
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PPTX
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
PDF
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
PDF
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
PDF
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
PDF
ICONIQ State of AI Report 2025 - The Builder's Playbook
Razin Mustafiz
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
🚀 Let’s Build Our First Slack Workflow! 🔧.pdf
SanjeetMishra29
 
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
ICONIQ State of AI Report 2025 - The Builder's Playbook
Razin Mustafiz
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 

MongoSF - Spatial MongoDB in OpenShift - script file

  • 1. 1 #commands for adding spatial data! 2 ! 3 #Take a look at the file first! 4 less parkcoord.json! 5 #get the file on the server! 6 scp parkcoord.json [email protected]:parks/data/! 7 ! 8 #ssh into the machine! 9 ssh [email protected]! 10 ! 11 #import into mongo! 12 mongoimport -d parks -c mongosf --type json --file parks/data/parkcoord.json -h $OPENSHIFT_NOSQL_DB_HOST -u admin -p <your … password>! 13 ! 14 #open the mongo shell! 15 mongo -u admin -p <your password> $OPENSHIFT_NOSQL_DB_HOST/parks! 16 ! 17 #build the index! 18 db.mongosf.ensureIndex({"pos":"2d"});! 19 ! 20 #Now some queries! 21 #simple spatial! 22 db.mongosf.find({"pos" : { "$near" : [-37, 41]}});! 23 ! 24 #spatial and text query using regex! 25 db.mongosf.find( { Name : /lincoln/i, pos : { $near : [-37,41] }} );! 26 ! 27 #geonear TODO! 28 db.runCommand({ geoNear : "mongosf", near : [-37,41], num : 10 });! 29 ! 30 ! 31 #create a new collection from scratch! 32 db.createCollection("mongosfuserloc");! 33 db.mongosfuserloc.ensureIndex( { pos : "2d" } );! 34 ! 35 #insert a new record! 36 db.mongosfuserloc.insert({ "created" : new Date(), "Notes" : 'just landed', "pos" : [-76.7302 , 25.5332 ] })! 37 ! ! 38 #quick query to make sure it worked! 39 db.mongosfuserloc.find( { pos : { $near : [-37,41] } } )! 40 ! 41 #add a second document closer to query point! 42 #this is an upsert - since we don't pass in the _id it creates a new record! 43 db.mongosfuserloc.save({ created : new Date(), Notes: 'that was a big step', pos : [-37.7302 , 40.5332 ]});! 44 ! 45 #one way to update original document! 46 myDoc = db.mongosfuserloc.findOne({_id : ObjectId("ID for the first object")});! 47 myDoc.Notes = "really the landing";! 48 db.mongosfuserloc.save(myDoc);! 49