SlideShare ist ein Scribd-Unternehmen logo
1 von 20
Beyond The Basics : Part 2
Analytics and the Aggregation Framework
Joe Drumgoole
Director of Developer Advocacy, EMEA
@jdrumgoole
V1.1
3
Beyond The Basics
– Storage Engines
• What storage engines are and how to pick them
– Aggregation Framework
• How to deploy advanced analytics processing right inside the database
– The BI Connector
• How to create visualisations and dashboards from your MongoDB data
– Authentication and Authorisation
• How to secure MongoDB, both on-premise and in the cloud
4
The Aggregation Framework
• An analytics engine for MongoDB
• What is analytics?
• Think of the two types of database, OLTP, OLAP
• OLTP : Online Transaction Processing
– Airline booking,
– ATMs,
– Taxi booking
• OLAP : Online Analytical Processing
– Which tickets make us most money?
– When do we need to refill our ATMs?
– How many cabs do we need to service the West End of London?
5
OLTP – Online Transaction processing
6
OLTP – Online Transaction processing
sum() avg()
7
The Aggregation Framework – A Processing Pipeline
Match Project Group SortLimit
• Think unix pipeline
• The output of one stage is passed to the input of the next stage
• Each stage performs one job
• Stages can be repeated
• Output is a cursor, a new collection or a view
8
Typical Goals of Aggregation Framework
• Columnar Analytics
• Reshaping data
• Unwinding arrays into individual documents
• Linking collections together
• Generating new data from old (collections and views)
9
Pipeline Operators
• $match
Filter documents
• $project
Reshape documents
• $group
Summarize documents
• $out
Create new collections
• $sort
Order documents
• $limit/$skip
Paginate documents
• $lookup
Join two collections together
• $unwind
Expand an array
10
Example Pipeline
Match Project Group Sort Out
• Find content
• Standard query
• Uses indexes
• Reduce doc
count
• Use first
• Select content
• Remove fields
• Add fields
• Reduce doc
size
• Looks at every
doc
• Collect content
• Sum, Avg etc.
• Rewrite _id
• Reduce doc
count
• Looks at every
doc
• Sort on fields
• Several sorts
allowed
• Ascending or
descending
• 100mb limit
• Allow Disk Use
• New collection
• $out overwrites
• Only one per
aggregate
• Last member
11
Example Document
MongoDB Enterprise > db.members.find( { "batchID" : 138,
"member.member_name" : "Joe Drumgoole" },
{ "_id" : 0, "member.chapters" : 0 } ).pretty()
{
"member" : {
"city" : "Dublin",
"events_attended" : 19,
"last_access_time" : ISODate("2017-04-25T12:40:55Z"),
"country" : "Ireland",
"member_id" : 99473492,
"is_organizer" : true,
"photo_thumb_url" : "https://secure.meetupstatic.com/photos/member/e/5/0/1/thumb_255178625.jpeg",
"location" : {
"type" : "Point",
"coordinates" : [
-6.25,
53.33000183105469
]
},
"member_name" : "Joe Drumgoole",
"join_time" : ISODate("2013-10-30T17:05:31Z")
},
"timestamp" : ISODate("2017-04-26T10:13:54.079Z"),
"batchID" : 138
}
12
Meetup Data
13
Group Document
MongoDB Enterprise > db.groups.findOne({ "batchID": 138 },
{ "group.photos" : 0, "group.topics" : 0, "group.location" : 0, "group.description" : 0, "group.organizers" : 0,
"group.category" : 0, "_id" : 0 } )
{
"batchID" : 138,
"timestamp" : ISODate("2017-04-26T10:12:06.388Z"),
"group" : {
"rsvps_per_event" : 39.285701751708984,
"repeat_rsvpers" : 62,
"upcoming_events" : 0,
"gender_female" : 0.039500001817941666,
"pro_join_date" : ISODate("2017-04-10T18:11:49Z"),
"id" : 10209022,
"city" : "Gent",
"member_count" : 399,
"average_age" : 35.15570068359375,
"status" : "Active",
"founded_date" : ISODate("2013-09-11T14:05:30Z"),
"urlname" : "mongodb-belgium",
"gender_male" : 0.9473999738693237,
"name" : "MongoDB Belgium",
"last_event" : ISODate("2015-06-16T18:00:00Z"),
"country" : "Belgium",
"gender_unknown" : 0.013199999928474426,
"past_events" : 7,
"gender_other" : 0,
"past_rsvps" : 275
}
}
14
Let’s Query for Groups
JD10Gen:apps jdrumgoole$ ./mug_analytics_main.py --stats groups --url mongodb-belgium DublinMUG
Processing : ['mongodb-belgium', 'DublinMUG']
pro
db.groups.aggregate( [
{"$match": {"batchID": 138, "group.urlname": {"$in": ["mongodb-belgium", "DublinMUG"]}}},
{"$project": {"founded": "$group.founded_date", "urlname": "$group.urlname", "_id": 0, "members":
"$group.member_count"}},
])
{'founded': '11-Sep-2013 14:05', 'members': 399, 'urlname': u'mongodb-belgium'}
{'founded': '14-Mar-2012 17:40', 'members': 847, 'urlname': u'DublinMUG'}
Wrote 2 records
JD10Gen:apps jdrumgoole$
15
Attendee Doc
MongoDB Enterprise > db.attendees.findOne( { "batchID" : 138 },
{ "info.event.description" : 0, "_id" : 0, "info.event.group" : 0,
"info.event.venue" : 0, "info.event.rating" : 0 } )
{
"info" : {
"attendee" : {
"status" : "attended",
"member" : {
"name" : "Former member"
},
"rsvp" : {
"response" : "yes",
}
},
"event" : {
"status" : "past",
"event_url" : "https://www.meetup.com/mongodb-belgium/events/162104572/",
"created" : ISODate("2014-01-23T09:10:20Z"),
"rsvp_limit" : 75,
"updated" : ISODate("2014-03-20T11:49:00Z"),
"visibility" : "public",
"yes_rsvp_count" : 75,
"time" : ISODate("2014-03-18T18:00:00Z"),
"headcount" : 0,
"id" : "162104572",
"name" : "MongoDB Belgium #1: the kickoff"
}
},
"timestamp" : ISODate("2017-04-26T10:14:30.129Z"),
"batchID" : 138
}
16
Search for New Members
JD10Gen:apps jdrumgoole$ ./mug_analytics_main.py --stats newmembers --url DublinMUG --sort join_date --format
csv --direction ascending --limit 10
Processing : ['DublinMUG']
Sorting on 'join_date' direction = 'ascending'
db.members.aggregate([
{"$match": {"batchID": 138}},
{"$unwind": "$member.chapters"},
{"$match": {"member.chapters.urlname": {"$in": ["DublinMUG"]}}},
{"$project": {"join_date": "$member.join_time", "_id": 0, "group": "$member.chapters.urlname", "name":
"$member.member_name"}},
{"$limit": 10}])
group,name,join_date
DublinMUG,Gosia,17-Apr-2017 12:51
DublinMUG,Luke Shiels,15-Apr-2017 14:00
DublinMUG,Silvia Sirbu,11-Apr-2017 12:00
DublinMUG,Steeve P.,04-Apr-2017 09:47
DublinMUG,Dafei W,30-Mar-2017 11:36
DublinMUG,Ross Norman,13-Mar-2017 11:30
DublinMUG,Grzegorz F.,08-Mar-2017 10:25
DublinMUG,Lucas Sacramento,07-Mar-2017 11:05
DublinMUG,David Blount,06-Mar-2017 12:33
DublinMUG,Luca Ballerini,06-Mar-2017 10:41
Wrote 10 records
JD10Gen:apps jdrumgoole$
17
Search for New Members This Year
JD10Gen:apps jdrumgoole$ ./mug_analytics_main.py --stats newmembers --url DublinMUG --sort join_date --format csv --
direction ascending --limit 10 --start 1-Jan-2017
Processing : ['DublinMUG']
Sorting on 'join_date' direction = 'ascending'
db.members.aggregate([
{"$match": {"batchID": 138}},
{"$unwind": "$member.chapters"},
{"$match": {"member.chapters.urlname": {"$in": ["DublinMUG"]}}},
{"$match": {"member.join_time": {"$gte": "2017-01-01T00:00:00"}}},
{"$project": {"join_date": "$member.join_time", "_id": 0, "group": "$member.chapters.urlname", "name":
"$member.member_name"}},
{"$limit": 10}])
group,name,join_date
DublinMUG,Gosia,17-Apr-2017 12:51
DublinMUG,Luke Shiels,15-Apr-2017 14:00
DublinMUG,Silvia Sirbu,11-Apr-2017 12:00
DublinMUG,Steeve P.,04-Apr-2017 09:47
DublinMUG,Dafei W,30-Mar-2017 11:36
DublinMUG,Ross Norman,13-Mar-2017 11:30
DublinMUG,Grzegorz F.,08-Mar-2017 10:25
DublinMUG,Lucas Sacramento,07-Mar-2017 11:05
DublinMUG,David Blount,06-Mar-2017 12:33
DublinMUG,Luca Ballerini,06-Mar-2017 10:41
Wrote 10 records
18
Turn an Aggregation into a View
• Only supported on MongoDB 3.4
• Views are a non-materialised view on a collection
MongoDB Enterprise > db.createView( "batch138",
"members",
[ { "$match" : { "batchID" : 138 }} ] )
{ "ok" : 1 }
MongoDB Enterprise >
• A view persists and will return new results each time a find is run
• A view looks just like a collection
• Must turn 3.4 compatibility on
MongoDB Enterprise > db.adminCommand( { setFeatureCompatibilityVersion: "3.4"} )
19
Useful Links
• The Aggregation Python class
https://github.com/jdrumgoole/mongodb_utils/blob/master/mongodb_utils/agg.py
• Aggregation docs
https://docs.mongodb.com/manual/aggregation/
• MongoDB Views in 3.4
https://docs.mongodb.com/manual/core/views/
20
Q&A

Weitere ähnliche Inhalte

Was ist angesagt?

The Aggregation Framework
The Aggregation FrameworkThe Aggregation Framework
The Aggregation Framework
MongoDB
 
Data Processing and Aggregation with MongoDB
Data Processing and Aggregation with MongoDB Data Processing and Aggregation with MongoDB
Data Processing and Aggregation with MongoDB
MongoDB
 

Was ist angesagt? (20)

Back to Basics Webinar 1: Introduction to NoSQL
Back to Basics Webinar 1: Introduction to NoSQLBack to Basics Webinar 1: Introduction to NoSQL
Back to Basics Webinar 1: Introduction to NoSQL
 
Agg framework selectgroup feb2015 v2
Agg framework selectgroup feb2015 v2Agg framework selectgroup feb2015 v2
Agg framework selectgroup feb2015 v2
 
Back to Basics Webinar 3: Schema Design Thinking in Documents
 Back to Basics Webinar 3: Schema Design Thinking in Documents Back to Basics Webinar 3: Schema Design Thinking in Documents
Back to Basics Webinar 3: Schema Design Thinking in Documents
 
The Aggregation Framework
The Aggregation FrameworkThe Aggregation Framework
The Aggregation Framework
 
Joins and Other Aggregation Enhancements Coming in MongoDB 3.2
Joins and Other Aggregation Enhancements Coming in MongoDB 3.2Joins and Other Aggregation Enhancements Coming in MongoDB 3.2
Joins and Other Aggregation Enhancements Coming in MongoDB 3.2
 
Webinar: Back to Basics: Thinking in Documents
Webinar: Back to Basics: Thinking in DocumentsWebinar: Back to Basics: Thinking in Documents
Webinar: Back to Basics: Thinking in Documents
 
Back to Basics, webinar 2: La tua prima applicazione MongoDB
Back to Basics, webinar 2: La tua prima applicazione MongoDBBack to Basics, webinar 2: La tua prima applicazione MongoDB
Back to Basics, webinar 2: La tua prima applicazione MongoDB
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Data Processing and Aggregation with MongoDB
Data Processing and Aggregation with MongoDB Data Processing and Aggregation with MongoDB
Data Processing and Aggregation with MongoDB
 
Conceptos bĂĄsicos. Seminario web 4: IndexaciĂłn avanzada, Ă­ndices de texto y g...
Conceptos bĂĄsicos. Seminario web 4: IndexaciĂłn avanzada, Ă­ndices de texto y g...Conceptos bĂĄsicos. Seminario web 4: IndexaciĂłn avanzada, Ă­ndices de texto y g...
Conceptos bĂĄsicos. Seminario web 4: IndexaciĂłn avanzada, Ă­ndices de texto y g...
 
Getting Started with MongoDB and NodeJS
Getting Started with MongoDB and NodeJSGetting Started with MongoDB and NodeJS
Getting Started with MongoDB and NodeJS
 
Back to Basics: My First MongoDB Application
Back to Basics: My First MongoDB ApplicationBack to Basics: My First MongoDB Application
Back to Basics: My First MongoDB Application
 
Indexing
IndexingIndexing
Indexing
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Introduction to MongoDB and Hadoop
Introduction to MongoDB and HadoopIntroduction to MongoDB and Hadoop
Introduction to MongoDB and Hadoop
 
Webinar: Data Processing and Aggregation Options
Webinar: Data Processing and Aggregation OptionsWebinar: Data Processing and Aggregation Options
Webinar: Data Processing and Aggregation Options
 
MongoDB
MongoDBMongoDB
MongoDB
 
Webinaire 2 de la sÊrie  Retour aux fondamentaux  : Votre première applicat...
Webinaire 2 de la sÊrie  Retour aux fondamentaux  : Votre première applicat...Webinaire 2 de la sÊrie  Retour aux fondamentaux  : Votre première applicat...
Webinaire 2 de la sÊrie  Retour aux fondamentaux  : Votre première applicat...
 
MongoDB Aggregation Framework
MongoDB Aggregation FrameworkMongoDB Aggregation Framework
MongoDB Aggregation Framework
 
High Performance Applications with MongoDB
High Performance Applications with MongoDBHigh Performance Applications with MongoDB
High Performance Applications with MongoDB
 

Ähnlich wie Beyond the Basics 2: Aggregation Framework

MongoDB Tick Data Presentation
MongoDB Tick Data PresentationMongoDB Tick Data Presentation
MongoDB Tick Data Presentation
MongoDB
 
Operational Intelligence with MongoDB Webinar
Operational Intelligence with MongoDB WebinarOperational Intelligence with MongoDB Webinar
Operational Intelligence with MongoDB Webinar
MongoDB
 
JLeRN Paradata Challenge at Dev8D 2012
JLeRN Paradata Challenge at Dev8D 2012JLeRN Paradata Challenge at Dev8D 2012
JLeRN Paradata Challenge at Dev8D 2012
Bharti Gupta
 
Social Data and Log Analysis Using MongoDB
Social Data and Log Analysis Using MongoDBSocial Data and Log Analysis Using MongoDB
Social Data and Log Analysis Using MongoDB
Takahiro Inoue
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1
Mohammad Qureshi
 

Ähnlich wie Beyond the Basics 2: Aggregation Framework (20)

IOOF IT System Modernisation
IOOF IT System ModernisationIOOF IT System Modernisation
IOOF IT System Modernisation
 
MongoDB Tick Data Presentation
MongoDB Tick Data PresentationMongoDB Tick Data Presentation
MongoDB Tick Data Presentation
 
Mongodb intro
Mongodb introMongodb intro
Mongodb intro
 
Webinar: Position and Trade Management with MongoDB
Webinar: Position and Trade Management with MongoDBWebinar: Position and Trade Management with MongoDB
Webinar: Position and Trade Management with MongoDB
 
Operational Intelligence with MongoDB Webinar
Operational Intelligence with MongoDB WebinarOperational Intelligence with MongoDB Webinar
Operational Intelligence with MongoDB Webinar
 
Streaming Data Pipelines with MongoDB and Kafka at ao.com
Streaming Data Pipelines with MongoDB and Kafka at ao.comStreaming Data Pipelines with MongoDB and Kafka at ao.com
Streaming Data Pipelines with MongoDB and Kafka at ao.com
 
Mongo at Sailthru (MongoNYC 2011)
Mongo at Sailthru (MongoNYC 2011)Mongo at Sailthru (MongoNYC 2011)
Mongo at Sailthru (MongoNYC 2011)
 
Webinar: Best Practices for Getting Started with MongoDB
Webinar: Best Practices for Getting Started with MongoDBWebinar: Best Practices for Getting Started with MongoDB
Webinar: Best Practices for Getting Started with MongoDB
 
MongoDB Best Practices
MongoDB Best PracticesMongoDB Best Practices
MongoDB Best Practices
 
Montreal Elasticsearch Meetup
Montreal Elasticsearch MeetupMontreal Elasticsearch Meetup
Montreal Elasticsearch Meetup
 
Webinar: Index Tuning and Evaluation
Webinar: Index Tuning and EvaluationWebinar: Index Tuning and Evaluation
Webinar: Index Tuning and Evaluation
 
Maintenance for MongoDB Replica Sets
Maintenance for MongoDB Replica SetsMaintenance for MongoDB Replica Sets
Maintenance for MongoDB Replica Sets
 
Webinar: Architecting Secure and Compliant Applications with MongoDB
Webinar: Architecting Secure and Compliant Applications with MongoDBWebinar: Architecting Secure and Compliant Applications with MongoDB
Webinar: Architecting Secure and Compliant Applications with MongoDB
 
Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDB
 
JLeRN Paradata Challenge at Dev8D 2012
JLeRN Paradata Challenge at Dev8D 2012JLeRN Paradata Challenge at Dev8D 2012
JLeRN Paradata Challenge at Dev8D 2012
 
Introduction to elasticsearch
Introduction to elasticsearchIntroduction to elasticsearch
Introduction to elasticsearch
 
Druid at naver.com - part 1
Druid at naver.com - part 1Druid at naver.com - part 1
Druid at naver.com - part 1
 
Social Data and Log Analysis Using MongoDB
Social Data and Log Analysis Using MongoDBSocial Data and Log Analysis Using MongoDB
Social Data and Log Analysis Using MongoDB
 
Cloud Foundry Monitoring How-To: Collecting Metrics and Logs
Cloud Foundry Monitoring How-To: Collecting Metrics and LogsCloud Foundry Monitoring How-To: Collecting Metrics and Logs
Cloud Foundry Monitoring How-To: Collecting Metrics and Logs
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1
 

Mehr von MongoDB

Mehr von MongoDB (20)

MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB AtlasMongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
 
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
 
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
 
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDBMongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
 
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
 
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series DataMongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
 
MongoDB SoCal 2020: MongoDB Atlas Jump Start
 MongoDB SoCal 2020: MongoDB Atlas Jump Start MongoDB SoCal 2020: MongoDB Atlas Jump Start
MongoDB SoCal 2020: MongoDB Atlas Jump Start
 
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
 
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
 
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
 
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
 
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your MindsetMongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
 
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB .local San Francisco 2020: MongoDB Atlas JumpstartMongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
 
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
 
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
 
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
 
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep DiveMongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
 
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & GolangMongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
 
MongoDB .local Paris 2020: Realm : l'ingrĂŠdient secret pour de meilleures app...
MongoDB .local Paris 2020: Realm : l'ingrĂŠdient secret pour de meilleures app...MongoDB .local Paris 2020: Realm : l'ingrĂŠdient secret pour de meilleures app...
MongoDB .local Paris 2020: Realm : l'ingrĂŠdient secret pour de meilleures app...
 
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
 

KĂźrzlich hochgeladen

Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdf
MarinCaroMartnezBerg
 
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
amitlee9823
 
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
amitlee9823
 
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
amitlee9823
 
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
amitlee9823
 
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get CytotecAbortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Riyadh +966572737505 get cytotec
 
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
amitlee9823
 
Probability Grade 10 Third Quarter Lessons
Probability Grade 10 Third Quarter LessonsProbability Grade 10 Third Quarter Lessons
Probability Grade 10 Third Quarter Lessons
JoseMangaJr1
 
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
amitlee9823
 

KĂźrzlich hochgeladen (20)

Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signals
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdf
 
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
 
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
 
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
 
Anomaly detection and data imputation within time series
Anomaly detection and data imputation within time seriesAnomaly detection and data imputation within time series
Anomaly detection and data imputation within time series
 
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
 
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
 
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get CytotecAbortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
 
Midocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxMidocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFx
 
Capstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics ProgramCapstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics Program
 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Research
 
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
 
Probability Grade 10 Third Quarter Lessons
Probability Grade 10 Third Quarter LessonsProbability Grade 10 Third Quarter Lessons
Probability Grade 10 Third Quarter Lessons
 
Predicting Loan Approval: A Data Science Project
Predicting Loan Approval: A Data Science ProjectPredicting Loan Approval: A Data Science Project
Predicting Loan Approval: A Data Science Project
 
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
 
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort ServiceBDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
 
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Marol Naka Call On 9920725232 With Body to body massage...
 
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
 

Beyond the Basics 2: Aggregation Framework

  • 1.
  • 2. Beyond The Basics : Part 2 Analytics and the Aggregation Framework Joe Drumgoole Director of Developer Advocacy, EMEA @jdrumgoole V1.1
  • 3. 3 Beyond The Basics – Storage Engines • What storage engines are and how to pick them – Aggregation Framework • How to deploy advanced analytics processing right inside the database – The BI Connector • How to create visualisations and dashboards from your MongoDB data – Authentication and Authorisation • How to secure MongoDB, both on-premise and in the cloud
  • 4. 4 The Aggregation Framework • An analytics engine for MongoDB • What is analytics? • Think of the two types of database, OLTP, OLAP • OLTP : Online Transaction Processing – Airline booking, – ATMs, – Taxi booking • OLAP : Online Analytical Processing – Which tickets make us most money? – When do we need to refill our ATMs? – How many cabs do we need to service the West End of London?
  • 5. 5 OLTP – Online Transaction processing
  • 6. 6 OLTP – Online Transaction processing sum() avg()
  • 7. 7 The Aggregation Framework – A Processing Pipeline Match Project Group SortLimit • Think unix pipeline • The output of one stage is passed to the input of the next stage • Each stage performs one job • Stages can be repeated • Output is a cursor, a new collection or a view
  • 8. 8 Typical Goals of Aggregation Framework • Columnar Analytics • Reshaping data • Unwinding arrays into individual documents • Linking collections together • Generating new data from old (collections and views)
  • 9. 9 Pipeline Operators • $match Filter documents • $project Reshape documents • $group Summarize documents • $out Create new collections • $sort Order documents • $limit/$skip Paginate documents • $lookup Join two collections together • $unwind Expand an array
  • 10. 10 Example Pipeline Match Project Group Sort Out • Find content • Standard query • Uses indexes • Reduce doc count • Use first • Select content • Remove fields • Add fields • Reduce doc size • Looks at every doc • Collect content • Sum, Avg etc. • Rewrite _id • Reduce doc count • Looks at every doc • Sort on fields • Several sorts allowed • Ascending or descending • 100mb limit • Allow Disk Use • New collection • $out overwrites • Only one per aggregate • Last member
  • 11. 11 Example Document MongoDB Enterprise > db.members.find( { "batchID" : 138, "member.member_name" : "Joe Drumgoole" }, { "_id" : 0, "member.chapters" : 0 } ).pretty() { "member" : { "city" : "Dublin", "events_attended" : 19, "last_access_time" : ISODate("2017-04-25T12:40:55Z"), "country" : "Ireland", "member_id" : 99473492, "is_organizer" : true, "photo_thumb_url" : "https://secure.meetupstatic.com/photos/member/e/5/0/1/thumb_255178625.jpeg", "location" : { "type" : "Point", "coordinates" : [ -6.25, 53.33000183105469 ] }, "member_name" : "Joe Drumgoole", "join_time" : ISODate("2013-10-30T17:05:31Z") }, "timestamp" : ISODate("2017-04-26T10:13:54.079Z"), "batchID" : 138 }
  • 13. 13 Group Document MongoDB Enterprise > db.groups.findOne({ "batchID": 138 }, { "group.photos" : 0, "group.topics" : 0, "group.location" : 0, "group.description" : 0, "group.organizers" : 0, "group.category" : 0, "_id" : 0 } ) { "batchID" : 138, "timestamp" : ISODate("2017-04-26T10:12:06.388Z"), "group" : { "rsvps_per_event" : 39.285701751708984, "repeat_rsvpers" : 62, "upcoming_events" : 0, "gender_female" : 0.039500001817941666, "pro_join_date" : ISODate("2017-04-10T18:11:49Z"), "id" : 10209022, "city" : "Gent", "member_count" : 399, "average_age" : 35.15570068359375, "status" : "Active", "founded_date" : ISODate("2013-09-11T14:05:30Z"), "urlname" : "mongodb-belgium", "gender_male" : 0.9473999738693237, "name" : "MongoDB Belgium", "last_event" : ISODate("2015-06-16T18:00:00Z"), "country" : "Belgium", "gender_unknown" : 0.013199999928474426, "past_events" : 7, "gender_other" : 0, "past_rsvps" : 275 } }
  • 14. 14 Let’s Query for Groups JD10Gen:apps jdrumgoole$ ./mug_analytics_main.py --stats groups --url mongodb-belgium DublinMUG Processing : ['mongodb-belgium', 'DublinMUG'] pro db.groups.aggregate( [ {"$match": {"batchID": 138, "group.urlname": {"$in": ["mongodb-belgium", "DublinMUG"]}}}, {"$project": {"founded": "$group.founded_date", "urlname": "$group.urlname", "_id": 0, "members": "$group.member_count"}}, ]) {'founded': '11-Sep-2013 14:05', 'members': 399, 'urlname': u'mongodb-belgium'} {'founded': '14-Mar-2012 17:40', 'members': 847, 'urlname': u'DublinMUG'} Wrote 2 records JD10Gen:apps jdrumgoole$
  • 15. 15 Attendee Doc MongoDB Enterprise > db.attendees.findOne( { "batchID" : 138 }, { "info.event.description" : 0, "_id" : 0, "info.event.group" : 0, "info.event.venue" : 0, "info.event.rating" : 0 } ) { "info" : { "attendee" : { "status" : "attended", "member" : { "name" : "Former member" }, "rsvp" : { "response" : "yes", } }, "event" : { "status" : "past", "event_url" : "https://www.meetup.com/mongodb-belgium/events/162104572/", "created" : ISODate("2014-01-23T09:10:20Z"), "rsvp_limit" : 75, "updated" : ISODate("2014-03-20T11:49:00Z"), "visibility" : "public", "yes_rsvp_count" : 75, "time" : ISODate("2014-03-18T18:00:00Z"), "headcount" : 0, "id" : "162104572", "name" : "MongoDB Belgium #1: the kickoff" } }, "timestamp" : ISODate("2017-04-26T10:14:30.129Z"), "batchID" : 138 }
  • 16. 16 Search for New Members JD10Gen:apps jdrumgoole$ ./mug_analytics_main.py --stats newmembers --url DublinMUG --sort join_date --format csv --direction ascending --limit 10 Processing : ['DublinMUG'] Sorting on 'join_date' direction = 'ascending' db.members.aggregate([ {"$match": {"batchID": 138}}, {"$unwind": "$member.chapters"}, {"$match": {"member.chapters.urlname": {"$in": ["DublinMUG"]}}}, {"$project": {"join_date": "$member.join_time", "_id": 0, "group": "$member.chapters.urlname", "name": "$member.member_name"}}, {"$limit": 10}]) group,name,join_date DublinMUG,Gosia,17-Apr-2017 12:51 DublinMUG,Luke Shiels,15-Apr-2017 14:00 DublinMUG,Silvia Sirbu,11-Apr-2017 12:00 DublinMUG,Steeve P.,04-Apr-2017 09:47 DublinMUG,Dafei W,30-Mar-2017 11:36 DublinMUG,Ross Norman,13-Mar-2017 11:30 DublinMUG,Grzegorz F.,08-Mar-2017 10:25 DublinMUG,Lucas Sacramento,07-Mar-2017 11:05 DublinMUG,David Blount,06-Mar-2017 12:33 DublinMUG,Luca Ballerini,06-Mar-2017 10:41 Wrote 10 records JD10Gen:apps jdrumgoole$
  • 17. 17 Search for New Members This Year JD10Gen:apps jdrumgoole$ ./mug_analytics_main.py --stats newmembers --url DublinMUG --sort join_date --format csv -- direction ascending --limit 10 --start 1-Jan-2017 Processing : ['DublinMUG'] Sorting on 'join_date' direction = 'ascending' db.members.aggregate([ {"$match": {"batchID": 138}}, {"$unwind": "$member.chapters"}, {"$match": {"member.chapters.urlname": {"$in": ["DublinMUG"]}}}, {"$match": {"member.join_time": {"$gte": "2017-01-01T00:00:00"}}}, {"$project": {"join_date": "$member.join_time", "_id": 0, "group": "$member.chapters.urlname", "name": "$member.member_name"}}, {"$limit": 10}]) group,name,join_date DublinMUG,Gosia,17-Apr-2017 12:51 DublinMUG,Luke Shiels,15-Apr-2017 14:00 DublinMUG,Silvia Sirbu,11-Apr-2017 12:00 DublinMUG,Steeve P.,04-Apr-2017 09:47 DublinMUG,Dafei W,30-Mar-2017 11:36 DublinMUG,Ross Norman,13-Mar-2017 11:30 DublinMUG,Grzegorz F.,08-Mar-2017 10:25 DublinMUG,Lucas Sacramento,07-Mar-2017 11:05 DublinMUG,David Blount,06-Mar-2017 12:33 DublinMUG,Luca Ballerini,06-Mar-2017 10:41 Wrote 10 records
  • 18. 18 Turn an Aggregation into a View • Only supported on MongoDB 3.4 • Views are a non-materialised view on a collection MongoDB Enterprise > db.createView( "batch138", "members", [ { "$match" : { "batchID" : 138 }} ] ) { "ok" : 1 } MongoDB Enterprise > • A view persists and will return new results each time a find is run • A view looks just like a collection • Must turn 3.4 compatibility on MongoDB Enterprise > db.adminCommand( { setFeatureCompatibilityVersion: "3.4"} )
  • 19. 19 Useful Links • The Aggregation Python class https://github.com/jdrumgoole/mongodb_utils/blob/master/mongodb_utils/agg.py • Aggregation docs https://docs.mongodb.com/manual/aggregation/ • MongoDB Views in 3.4 https://docs.mongodb.com/manual/core/views/