SlideShare a Scribd company logo
Lab: Map/Reduce Views (30 minutes)
Bradley Holt, Developer Advocate
Thursday, February 9, 2017
CouchDB Developer Day
@BradleyHolt
Prerequisite: Replication Lab
@BradleyHolt
Key Concepts
 Design documents
 Views
 Map functions
 Reduce functions
@BradleyHolt
http-console
$ npm install http-console -g
@BradleyHolthttps://github.com/cloudhead/http-console
http-console
$ npm install http-console -g
$ http-console 127.0.0.1:5984
@BradleyHolthttps://github.com/cloudhead/http-console
http-console
$ npm install http-console -g
$ http-console 127.0.0.1:5984
> http-console 0.6.3
> Welcome, enter .help if you're lost.
> Connecting to 127.0.0.1 on port 5984.
@BradleyHolthttps://github.com/cloudhead/http-console
Connecting to CouchDB 2.0
$ http-console root:passw0rd@127.0.0.1:5984 --json
@BradleyHolt
Connecting to CouchDB 2.0
$ http-console root:passw0rd@127.0.0.1:5984 --json
> http-console 0.6.3
> Welcome, enter .help if you're lost.
> Connecting to 127.0.0.1 on port 5984.
@BradleyHolt
Connecting to IBM Cloudant
$ http-console https://bradley-holt:passw0rd@bradley-holt.cloudant.com --json
@BradleyHolt
Connecting to IBM Cloudant
$ http-console https://bradley-holt:passw0rd@bradley-holt.cloudant.com --json
> http-console 0.6.3
> Welcome, enter .help if you're lost.
> Connecting to bradley-holt.cloudant.com on port 443.
@BradleyHolt
Create a Design Document
/>
@BradleyHolt
Create a Design Document
/> /kittens
@BradleyHolt
Create a Design Document
/kittens>
@BradleyHolt
Create a Design Document
/kittens> PUT /_design/kittens
@BradleyHolt
Create a Design Document
/kittens> PUT /_design/kittens
... { "views": { "by_age": { "map": "function(doc) { emit(doc.age_weeks) }" } } }
@BradleyHolt
Create a Design Document
/kittens> PUT /_design/kittens
... { "views": { "by_age": { "map": "function(doc) { emit(doc.age_weeks) }" } } }
HTTP/1.1 201 Created
Content-Type: application/json
{
ok: true,
id: '_design/kittens',
rev: '1-c38a0039638b950f64e02c51fe2e9229'
}
@BradleyHolt
Get the Design Document
/kittens>
@BradleyHolt
Get the Design Document
/kittens> GET /_design/kittens
@BradleyHolt
Get the Design Document
/kittens> GET /_design/kittens
HTTP/1.1 200 OK
Content-Type: application/json
{
_id: '_design/kittens',
_rev: '1-c38a0039638b950f64e02c51fe2e9229',
views: {
by_age: { map: 'function(doc) { emit(doc.age_weeks) }' }
}
}
@BradleyHolt
Query a View
/kittens>
@BradleyHolt
Query a View
/kittens> GET /_design/kittens/_view/by_age
@BradleyHolt
Query a View
/kittens> GET /_design/kittens/_view/by_age
HTTP/1.1 200 OK
Content-Type: application/json
{
total_rows: 5,
offset: 0,
rows: [
{ id: 'smokey', key: 3, value: null },
{ id: 'tiger', key: 7, value: null },
{ id: 'daisy', key: 9, value: null },
{ id: 'mittens', key: 10, value: null },
{ id: 'lily', key: 16, value: null }
]
}
@BradleyHolt
Query a View with Start Key and End Key
/kittens>
@BradleyHolt
Query a View with Start Key and End Key
/kittens> GET /_design/kittens/_view/by_age?startkey=7&endkey=10
@BradleyHolt
Query a View with Start Key and End Key
/kittens> GET /_design/kittens/_view/by_age?startkey=7&endkey=10
HTTP/1.1 200 OK
Content-Type: application/json
{
total_rows: 5,
offset: 1,
rows: [
{ id: 'tiger', key: 7, value: null },
{ id: 'daisy', key: 9, value: null },
{ id: 'mittens', key: 10, value: null }
]
}
@BradleyHolt
Add a Reduce Function
/kittens>
@BradleyHolt
Add a Reduce Function
/kittens> GET /_design/kittens
@BradleyHolt
Add a Reduce Function
/kittens> GET /_design/kittens
HTTP/1.1 200 OK
Content-Type: application/json
{
_id: '_design/kittens',
_rev: '1-c38a0039638b950f64e02c51fe2e9229',
views: {
by_age: { map: 'function(doc) { emit(doc.age_weeks) }' }
}
}
@BradleyHolt
Add a Reduce Function
/kittens>
@BradleyHolt
Add a Reduce Function
/kittens> PUT /_design/kittens?rev=1-c38a0039638b950f64e02c51fe2e9229
@BradleyHolt
Add a Reduce Function
/kittens> PUT /_design/kittens?rev=1-c38a0039638b950f64e02c51fe2e9229
... { "views": { "by_age": { "map": "function(doc) { emit(doc.age_weeks, doc.weight_kilograms) }", "reduce":
"_stats" } } }
@BradleyHolt
Add a Reduce Function
/kittens> PUT /_design/kittens?rev=1-c38a0039638b950f64e02c51fe2e9229
... { "views": { "by_age": { "map": "function(doc) { emit(doc.age_weeks, doc.weight_kilograms) }", "reduce":
"_stats" } } }
HTTP/1.1 201 Created
Content-Type: application/json
{
ok: true,
id: '_design/kittens',
rev: '2-a64e3539068221e7b4eaa94917faed5f'
}
@BradleyHolt
Query a View with a Reduce Function
/kittens>
@BradleyHolt
Query a View with a Reduce Function
/kittens> GET /_design/kittens/_view/by_age
@BradleyHolt
Query a View with a Reduce Function
/kittens> GET /_design/kittens/_view/by_age
HTTP/1.1 200 OK
Content-Type: application/json
{
rows: [
{
key: null,
value: {
sum: 4.8919999999999995,
count: 5,
min: 0.403,
max: 1.95,
sumsqr: 6.15185
}
}
]
}
@BradleyHolt
Try It On Your Own
1. Create an view of kittens by weight_kilograms, using age_weeks as the value and
using a _stats reduce function
2. Find kittens weighing less than 1 kilogram (use the reduce=false parameter)
3. Find the stats of kittens weighing less than 1 kilogram
@BradleyHolt
Lab: Map/Reduce Views
CouchDB Developer Day
@BradleyHolt

More Related Content

What's hot

Javascript Continues Integration in Jenkins with AngularJS
Javascript Continues Integration in Jenkins with AngularJSJavascript Continues Integration in Jenkins with AngularJS
Javascript Continues Integration in Jenkins with AngularJSLadislav Prskavec
 
Scrapy workshop
Scrapy workshopScrapy workshop
Scrapy workshop
Karthik Ananth
 
2015 555 kharchenko_ppt
2015 555 kharchenko_ppt2015 555 kharchenko_ppt
2015 555 kharchenko_ppt
Maxym Kharchenko
 
Fun with Python
Fun with PythonFun with Python
Fun with Python
Narong Intiruk
 
How to Scrap Any Website's content using ScrapyTutorial of How to scrape (cra...
How to Scrap Any Website's content using ScrapyTutorial of How to scrape (cra...How to Scrap Any Website's content using ScrapyTutorial of How to scrape (cra...
How to Scrap Any Website's content using ScrapyTutorial of How to scrape (cra...
Anton
 
Awesome Traefik - Ingress Controller for Kubernetes - Swapnasagar Pradhan
Awesome Traefik - Ingress Controller for Kubernetes - Swapnasagar PradhanAwesome Traefik - Ingress Controller for Kubernetes - Swapnasagar Pradhan
Awesome Traefik - Ingress Controller for Kubernetes - Swapnasagar Pradhan
Ajeet Singh Raina
 
PHP 机智问答
PHP 机智问答PHP 机智问答
PHP 机智问答
Shengyou Fan
 
Visualizing ORACLE performance data with R @ #C16LV
Visualizing ORACLE performance data with R @ #C16LVVisualizing ORACLE performance data with R @ #C16LV
Visualizing ORACLE performance data with R @ #C16LV
Maxym Kharchenko
 
Eve - REST API for Humans™
Eve - REST API for Humans™Eve - REST API for Humans™
Eve - REST API for Humans™
Nicola Iarocci
 
Commit2015 kharchenko - python generators - ext
Commit2015   kharchenko - python generators - extCommit2015   kharchenko - python generators - ext
Commit2015 kharchenko - python generators - ext
Maxym Kharchenko
 
G*なクラウド ~雲のかなたに~
G*なクラウド ~雲のかなたに~G*なクラウド ~雲のかなたに~
G*なクラウド ~雲のかなたに~
Tsuyoshi Yamamoto
 
Sensu wrapper-sensu-summit
Sensu wrapper-sensu-summitSensu wrapper-sensu-summit
Sensu wrapper-sensu-summit
Lee Briggs
 
REST with Eve and Python
REST with Eve and PythonREST with Eve and Python
REST with Eve and Python
PiXeL16
 
gunicorn introduction
gunicorn introductiongunicorn introduction
gunicorn introduction
Adam Lowry
 
Pydata-Python tools for webscraping
Pydata-Python tools for webscrapingPydata-Python tools for webscraping
Pydata-Python tools for webscraping
Jose Manuel Ortega Candel
 
Node collaboration - Exported Resources and PuppetDB
Node collaboration - Exported Resources and PuppetDBNode collaboration - Exported Resources and PuppetDB
Node collaboration - Exported Resources and PuppetDB
m_richardson
 
Tupperware
TupperwareTupperware
Tupperware
Hiromu Shioya
 
RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK - Nicola Iarocci - Co...
RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK -  Nicola Iarocci - Co...RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK -  Nicola Iarocci - Co...
RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK - Nicola Iarocci - Co...
Codemotion
 
Spatial script for my JS.Everywhere 2012
Spatial script for my JS.Everywhere 2012Spatial script for my JS.Everywhere 2012
Spatial script for my JS.Everywhere 2012Steven Pousty
 

What's hot (20)

Javascript Continues Integration in Jenkins with AngularJS
Javascript Continues Integration in Jenkins with AngularJSJavascript Continues Integration in Jenkins with AngularJS
Javascript Continues Integration in Jenkins with AngularJS
 
Scrapy workshop
Scrapy workshopScrapy workshop
Scrapy workshop
 
2015 555 kharchenko_ppt
2015 555 kharchenko_ppt2015 555 kharchenko_ppt
2015 555 kharchenko_ppt
 
Fun with Python
Fun with PythonFun with Python
Fun with Python
 
How to Scrap Any Website's content using ScrapyTutorial of How to scrape (cra...
How to Scrap Any Website's content using ScrapyTutorial of How to scrape (cra...How to Scrap Any Website's content using ScrapyTutorial of How to scrape (cra...
How to Scrap Any Website's content using ScrapyTutorial of How to scrape (cra...
 
Awesome Traefik - Ingress Controller for Kubernetes - Swapnasagar Pradhan
Awesome Traefik - Ingress Controller for Kubernetes - Swapnasagar PradhanAwesome Traefik - Ingress Controller for Kubernetes - Swapnasagar Pradhan
Awesome Traefik - Ingress Controller for Kubernetes - Swapnasagar Pradhan
 
PHP 机智问答
PHP 机智问答PHP 机智问答
PHP 机智问答
 
Visualizing ORACLE performance data with R @ #C16LV
Visualizing ORACLE performance data with R @ #C16LVVisualizing ORACLE performance data with R @ #C16LV
Visualizing ORACLE performance data with R @ #C16LV
 
G* on GAE/J 挑戦編
G* on GAE/J 挑戦編G* on GAE/J 挑戦編
G* on GAE/J 挑戦編
 
Eve - REST API for Humans™
Eve - REST API for Humans™Eve - REST API for Humans™
Eve - REST API for Humans™
 
Commit2015 kharchenko - python generators - ext
Commit2015   kharchenko - python generators - extCommit2015   kharchenko - python generators - ext
Commit2015 kharchenko - python generators - ext
 
G*なクラウド ~雲のかなたに~
G*なクラウド ~雲のかなたに~G*なクラウド ~雲のかなたに~
G*なクラウド ~雲のかなたに~
 
Sensu wrapper-sensu-summit
Sensu wrapper-sensu-summitSensu wrapper-sensu-summit
Sensu wrapper-sensu-summit
 
REST with Eve and Python
REST with Eve and PythonREST with Eve and Python
REST with Eve and Python
 
gunicorn introduction
gunicorn introductiongunicorn introduction
gunicorn introduction
 
Pydata-Python tools for webscraping
Pydata-Python tools for webscrapingPydata-Python tools for webscraping
Pydata-Python tools for webscraping
 
Node collaboration - Exported Resources and PuppetDB
Node collaboration - Exported Resources and PuppetDBNode collaboration - Exported Resources and PuppetDB
Node collaboration - Exported Resources and PuppetDB
 
Tupperware
TupperwareTupperware
Tupperware
 
RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK - Nicola Iarocci - Co...
RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK -  Nicola Iarocci - Co...RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK -  Nicola Iarocci - Co...
RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK - Nicola Iarocci - Co...
 
Spatial script for my JS.Everywhere 2012
Spatial script for my JS.Everywhere 2012Spatial script for my JS.Everywhere 2012
Spatial script for my JS.Everywhere 2012
 

Similar to CouchDB Day NYC 2017: MapReduce Views

CouchDB Day NYC 2017: Core HTTP API
CouchDB Day NYC 2017: Core HTTP APICouchDB Day NYC 2017: Core HTTP API
CouchDB Day NYC 2017: Core HTTP API
IBM Cloud Data Services
 
Ruby gems
Ruby gemsRuby gems
Ruby gems
Papp Laszlo
 
Reactive Type safe Webcomponents with skateJS
Reactive Type safe Webcomponents with skateJSReactive Type safe Webcomponents with skateJS
Reactive Type safe Webcomponents with skateJS
Martin Hochel
 
Puppet at GitHub
Puppet at GitHubPuppet at GitHub
Puppet at GitHub
Puppet
 
Stick to the rules - Consumer Driven Contracts. 2015.07 Confitura
Stick to the rules - Consumer Driven Contracts. 2015.07 ConfituraStick to the rules - Consumer Driven Contracts. 2015.07 Confitura
Stick to the rules - Consumer Driven Contracts. 2015.07 ConfituraMarcin Grzejszczak
 
Spring Into Kubernetes DFW
Spring Into Kubernetes DFWSpring Into Kubernetes DFW
Spring Into Kubernetes DFW
VMware Tanzu
 
Python Code Camp for Professionals 3/4
Python Code Camp for Professionals 3/4Python Code Camp for Professionals 3/4
Python Code Camp for Professionals 3/4
DEVCON
 
KubeCon EU 2016: Kubernetes and the Potential for Higher Level Interfaces
KubeCon EU 2016: Kubernetes and the Potential for Higher Level InterfacesKubeCon EU 2016: Kubernetes and the Potential for Higher Level Interfaces
KubeCon EU 2016: Kubernetes and the Potential for Higher Level Interfaces
KubeAcademy
 
The Big Picture and How to Get Started
The Big Picture and How to Get StartedThe Big Picture and How to Get Started
The Big Picture and How to Get Started
guest1af57e
 
LF_APIStrat17_REST API Microversions
LF_APIStrat17_REST API Microversions LF_APIStrat17_REST API Microversions
LF_APIStrat17_REST API Microversions
LF_APIStrat
 
Php on the Web and Desktop
Php on the Web and DesktopPhp on the Web and Desktop
Php on the Web and Desktop
Elizabeth Smith
 
[AngularJS] From Angular to Mobile in 30 minutes
[AngularJS] From Angular to Mobile in 30 minutes[AngularJS] From Angular to Mobile in 30 minutes
[AngularJS] From Angular to Mobile in 30 minutes
Globant
 
Becoming a Git Master
Becoming a Git MasterBecoming a Git Master
Becoming a Git Master
Nicola Paolucci
 
Mojolicious - A new hope
Mojolicious - A new hopeMojolicious - A new hope
Mojolicious - A new hope
Marcus Ramberg
 
RESTFul API Design and Documentation - an Introduction
RESTFul API Design and Documentation - an IntroductionRESTFul API Design and Documentation - an Introduction
RESTFul API Design and Documentation - an Introduction
Miredot
 
What's New in ZF 1.10
What's New in ZF 1.10What's New in ZF 1.10
What's New in ZF 1.10
Ralph Schindler
 
Kube Your Enthusiasm - Tyler Britten
Kube Your Enthusiasm - Tyler BrittenKube Your Enthusiasm - Tyler Britten
Kube Your Enthusiasm - Tyler Britten
VMware Tanzu
 
Modern Web Development with Perl
Modern Web Development with PerlModern Web Development with Perl
Modern Web Development with Perl
Dave Cross
 

Similar to CouchDB Day NYC 2017: MapReduce Views (20)

CouchDB Day NYC 2017: Core HTTP API
CouchDB Day NYC 2017: Core HTTP APICouchDB Day NYC 2017: Core HTTP API
CouchDB Day NYC 2017: Core HTTP API
 
Ruby gems
Ruby gemsRuby gems
Ruby gems
 
Reactive Type safe Webcomponents with skateJS
Reactive Type safe Webcomponents with skateJSReactive Type safe Webcomponents with skateJS
Reactive Type safe Webcomponents with skateJS
 
Puppet at GitHub
Puppet at GitHubPuppet at GitHub
Puppet at GitHub
 
Stick to the rules - Consumer Driven Contracts. 2015.07 Confitura
Stick to the rules - Consumer Driven Contracts. 2015.07 ConfituraStick to the rules - Consumer Driven Contracts. 2015.07 Confitura
Stick to the rules - Consumer Driven Contracts. 2015.07 Confitura
 
Spring Into Kubernetes DFW
Spring Into Kubernetes DFWSpring Into Kubernetes DFW
Spring Into Kubernetes DFW
 
Python Code Camp for Professionals 3/4
Python Code Camp for Professionals 3/4Python Code Camp for Professionals 3/4
Python Code Camp for Professionals 3/4
 
KubeCon EU 2016: Kubernetes and the Potential for Higher Level Interfaces
KubeCon EU 2016: Kubernetes and the Potential for Higher Level InterfacesKubeCon EU 2016: Kubernetes and the Potential for Higher Level Interfaces
KubeCon EU 2016: Kubernetes and the Potential for Higher Level Interfaces
 
The Big Picture and How to Get Started
The Big Picture and How to Get StartedThe Big Picture and How to Get Started
The Big Picture and How to Get Started
 
LF_APIStrat17_REST API Microversions
LF_APIStrat17_REST API Microversions LF_APIStrat17_REST API Microversions
LF_APIStrat17_REST API Microversions
 
Php on the Web and Desktop
Php on the Web and DesktopPhp on the Web and Desktop
Php on the Web and Desktop
 
[AngularJS] From Angular to Mobile in 30 minutes
[AngularJS] From Angular to Mobile in 30 minutes[AngularJS] From Angular to Mobile in 30 minutes
[AngularJS] From Angular to Mobile in 30 minutes
 
Becoming a Git Master
Becoming a Git MasterBecoming a Git Master
Becoming a Git Master
 
Rack Middleware
Rack MiddlewareRack Middleware
Rack Middleware
 
Mojolicious - A new hope
Mojolicious - A new hopeMojolicious - A new hope
Mojolicious - A new hope
 
RESTFul API Design and Documentation - an Introduction
RESTFul API Design and Documentation - an IntroductionRESTFul API Design and Documentation - an Introduction
RESTFul API Design and Documentation - an Introduction
 
Introduction to angular js
Introduction to angular jsIntroduction to angular js
Introduction to angular js
 
What's New in ZF 1.10
What's New in ZF 1.10What's New in ZF 1.10
What's New in ZF 1.10
 
Kube Your Enthusiasm - Tyler Britten
Kube Your Enthusiasm - Tyler BrittenKube Your Enthusiasm - Tyler Britten
Kube Your Enthusiasm - Tyler Britten
 
Modern Web Development with Perl
Modern Web Development with PerlModern Web Development with Perl
Modern Web Development with Perl
 

More from IBM Cloud Data Services

CouchDB Day NYC 2017: Using Geospatial Data in Cloudant & CouchDB
CouchDB Day NYC 2017: Using Geospatial Data in Cloudant & CouchDBCouchDB Day NYC 2017: Using Geospatial Data in Cloudant & CouchDB
CouchDB Day NYC 2017: Using Geospatial Data in Cloudant & CouchDB
IBM Cloud Data Services
 
Practical Use of a NoSQL
Practical Use of a NoSQLPractical Use of a NoSQL
Practical Use of a NoSQL
IBM Cloud Data Services
 
I See NoSQL Document Stores in Geospatial Applications
I See NoSQL Document Stores in Geospatial ApplicationsI See NoSQL Document Stores in Geospatial Applications
I See NoSQL Document Stores in Geospatial Applications
IBM Cloud Data Services
 
Webinar: The Anatomy of the Cloudant Data Layer
Webinar: The Anatomy of the Cloudant Data LayerWebinar: The Anatomy of the Cloudant Data Layer
Webinar: The Anatomy of the Cloudant Data Layer
IBM Cloud Data Services
 
NoSQL for SQL Users
NoSQL for SQL UsersNoSQL for SQL Users
NoSQL for SQL Users
IBM Cloud Data Services
 
dashDB: the GIS professional’s bridge to mainstream IT systems
dashDB: the GIS professional’s bridge to mainstream IT systemsdashDB: the GIS professional’s bridge to mainstream IT systems
dashDB: the GIS professional’s bridge to mainstream IT systems
IBM Cloud Data Services
 
Cloud Data Services: A Brand New Ballgame for Business
Cloud Data Services: A  Brand New Ballgame for BusinessCloud Data Services: A  Brand New Ballgame for Business
Cloud Data Services: A Brand New Ballgame for Business
IBM Cloud Data Services
 
Practical Use of a NoSQL Database
Practical Use of a NoSQL DatabasePractical Use of a NoSQL Database
Practical Use of a NoSQL Database
IBM Cloud Data Services
 
SQL To NoSQL - Top 6 Questions Before Making The Move
SQL To NoSQL - Top 6 Questions Before Making The MoveSQL To NoSQL - Top 6 Questions Before Making The Move
SQL To NoSQL - Top 6 Questions Before Making The Move
IBM Cloud Data Services
 
Machine Learning with Apache Spark
Machine Learning with Apache SparkMachine Learning with Apache Spark
Machine Learning with Apache Spark
IBM Cloud Data Services
 
Mobile App Development With IBM Cloudant
Mobile App Development With IBM CloudantMobile App Development With IBM Cloudant
Mobile App Development With IBM Cloudant
IBM Cloud Data Services
 
IBM Cognos Business Intelligence using dashDB
IBM Cognos Business Intelligence using dashDBIBM Cognos Business Intelligence using dashDB
IBM Cognos Business Intelligence using dashDB
IBM Cloud Data Services
 
Run Oracle Apps in the Cloud with dashDB
Run Oracle Apps in the Cloud with dashDBRun Oracle Apps in the Cloud with dashDB
Run Oracle Apps in the Cloud with dashDB
IBM Cloud Data Services
 
Analyzing GeoSpatial data with IBM Cloud Data Services & Esri ArcGIS
Analyzing GeoSpatial data with IBM Cloud Data Services & Esri ArcGISAnalyzing GeoSpatial data with IBM Cloud Data Services & Esri ArcGIS
Analyzing GeoSpatial data with IBM Cloud Data Services & Esri ArcGISIBM Cloud Data Services
 
Get Started Quickly with IBM's Hadoop as a Service
Get Started Quickly with IBM's Hadoop as a ServiceGet Started Quickly with IBM's Hadoop as a Service
Get Started Quickly with IBM's Hadoop as a Service
IBM Cloud Data Services
 
Introducing dashDB MPP: The Power of Data Warehousing in the Cloud
Introducing dashDB MPP: The Power of Data Warehousing in the CloudIntroducing dashDB MPP: The Power of Data Warehousing in the Cloud
Introducing dashDB MPP: The Power of Data Warehousing in the Cloud
IBM Cloud Data Services
 

More from IBM Cloud Data Services (16)

CouchDB Day NYC 2017: Using Geospatial Data in Cloudant & CouchDB
CouchDB Day NYC 2017: Using Geospatial Data in Cloudant & CouchDBCouchDB Day NYC 2017: Using Geospatial Data in Cloudant & CouchDB
CouchDB Day NYC 2017: Using Geospatial Data in Cloudant & CouchDB
 
Practical Use of a NoSQL
Practical Use of a NoSQLPractical Use of a NoSQL
Practical Use of a NoSQL
 
I See NoSQL Document Stores in Geospatial Applications
I See NoSQL Document Stores in Geospatial ApplicationsI See NoSQL Document Stores in Geospatial Applications
I See NoSQL Document Stores in Geospatial Applications
 
Webinar: The Anatomy of the Cloudant Data Layer
Webinar: The Anatomy of the Cloudant Data LayerWebinar: The Anatomy of the Cloudant Data Layer
Webinar: The Anatomy of the Cloudant Data Layer
 
NoSQL for SQL Users
NoSQL for SQL UsersNoSQL for SQL Users
NoSQL for SQL Users
 
dashDB: the GIS professional’s bridge to mainstream IT systems
dashDB: the GIS professional’s bridge to mainstream IT systemsdashDB: the GIS professional’s bridge to mainstream IT systems
dashDB: the GIS professional’s bridge to mainstream IT systems
 
Cloud Data Services: A Brand New Ballgame for Business
Cloud Data Services: A  Brand New Ballgame for BusinessCloud Data Services: A  Brand New Ballgame for Business
Cloud Data Services: A Brand New Ballgame for Business
 
Practical Use of a NoSQL Database
Practical Use of a NoSQL DatabasePractical Use of a NoSQL Database
Practical Use of a NoSQL Database
 
SQL To NoSQL - Top 6 Questions Before Making The Move
SQL To NoSQL - Top 6 Questions Before Making The MoveSQL To NoSQL - Top 6 Questions Before Making The Move
SQL To NoSQL - Top 6 Questions Before Making The Move
 
Machine Learning with Apache Spark
Machine Learning with Apache SparkMachine Learning with Apache Spark
Machine Learning with Apache Spark
 
Mobile App Development With IBM Cloudant
Mobile App Development With IBM CloudantMobile App Development With IBM Cloudant
Mobile App Development With IBM Cloudant
 
IBM Cognos Business Intelligence using dashDB
IBM Cognos Business Intelligence using dashDBIBM Cognos Business Intelligence using dashDB
IBM Cognos Business Intelligence using dashDB
 
Run Oracle Apps in the Cloud with dashDB
Run Oracle Apps in the Cloud with dashDBRun Oracle Apps in the Cloud with dashDB
Run Oracle Apps in the Cloud with dashDB
 
Analyzing GeoSpatial data with IBM Cloud Data Services & Esri ArcGIS
Analyzing GeoSpatial data with IBM Cloud Data Services & Esri ArcGISAnalyzing GeoSpatial data with IBM Cloud Data Services & Esri ArcGIS
Analyzing GeoSpatial data with IBM Cloud Data Services & Esri ArcGIS
 
Get Started Quickly with IBM's Hadoop as a Service
Get Started Quickly with IBM's Hadoop as a ServiceGet Started Quickly with IBM's Hadoop as a Service
Get Started Quickly with IBM's Hadoop as a Service
 
Introducing dashDB MPP: The Power of Data Warehousing in the Cloud
Introducing dashDB MPP: The Power of Data Warehousing in the CloudIntroducing dashDB MPP: The Power of Data Warehousing in the Cloud
Introducing dashDB MPP: The Power of Data Warehousing in the Cloud
 

Recently uploaded

OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
Hornet Dynamics
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
Aftab Hussain
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
Rakesh Kumar R
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
Octavian Nadolu
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
timtebeek1
 
AI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website CreatorAI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website Creator
Google
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
Łukasz Chruściel
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Crescat
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
Google
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
Alina Yurenko
 
Launch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in MinutesLaunch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in Minutes
Roshan Dwivedi
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
Ayan Halder
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
Boni García
 

Recently uploaded (20)

OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
 
AI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website CreatorAI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website Creator
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
 
Launch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in MinutesLaunch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in Minutes
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
 

CouchDB Day NYC 2017: MapReduce Views

  • 1. Lab: Map/Reduce Views (30 minutes) Bradley Holt, Developer Advocate Thursday, February 9, 2017 CouchDB Developer Day @BradleyHolt
  • 3.
  • 4. Key Concepts  Design documents  Views  Map functions  Reduce functions @BradleyHolt
  • 5. http-console $ npm install http-console -g @BradleyHolthttps://github.com/cloudhead/http-console
  • 6. http-console $ npm install http-console -g $ http-console 127.0.0.1:5984 @BradleyHolthttps://github.com/cloudhead/http-console
  • 7. http-console $ npm install http-console -g $ http-console 127.0.0.1:5984 > http-console 0.6.3 > Welcome, enter .help if you're lost. > Connecting to 127.0.0.1 on port 5984. @BradleyHolthttps://github.com/cloudhead/http-console
  • 8. Connecting to CouchDB 2.0 $ http-console root:passw0rd@127.0.0.1:5984 --json @BradleyHolt
  • 9. Connecting to CouchDB 2.0 $ http-console root:passw0rd@127.0.0.1:5984 --json > http-console 0.6.3 > Welcome, enter .help if you're lost. > Connecting to 127.0.0.1 on port 5984. @BradleyHolt
  • 10. Connecting to IBM Cloudant $ http-console https://bradley-holt:passw0rd@bradley-holt.cloudant.com --json @BradleyHolt
  • 11. Connecting to IBM Cloudant $ http-console https://bradley-holt:passw0rd@bradley-holt.cloudant.com --json > http-console 0.6.3 > Welcome, enter .help if you're lost. > Connecting to bradley-holt.cloudant.com on port 443. @BradleyHolt
  • 12. Create a Design Document /> @BradleyHolt
  • 13. Create a Design Document /> /kittens @BradleyHolt
  • 14. Create a Design Document /kittens> @BradleyHolt
  • 15. Create a Design Document /kittens> PUT /_design/kittens @BradleyHolt
  • 16. Create a Design Document /kittens> PUT /_design/kittens ... { "views": { "by_age": { "map": "function(doc) { emit(doc.age_weeks) }" } } } @BradleyHolt
  • 17. Create a Design Document /kittens> PUT /_design/kittens ... { "views": { "by_age": { "map": "function(doc) { emit(doc.age_weeks) }" } } } HTTP/1.1 201 Created Content-Type: application/json { ok: true, id: '_design/kittens', rev: '1-c38a0039638b950f64e02c51fe2e9229' } @BradleyHolt
  • 18. Get the Design Document /kittens> @BradleyHolt
  • 19. Get the Design Document /kittens> GET /_design/kittens @BradleyHolt
  • 20. Get the Design Document /kittens> GET /_design/kittens HTTP/1.1 200 OK Content-Type: application/json { _id: '_design/kittens', _rev: '1-c38a0039638b950f64e02c51fe2e9229', views: { by_age: { map: 'function(doc) { emit(doc.age_weeks) }' } } } @BradleyHolt
  • 22. Query a View /kittens> GET /_design/kittens/_view/by_age @BradleyHolt
  • 23. Query a View /kittens> GET /_design/kittens/_view/by_age HTTP/1.1 200 OK Content-Type: application/json { total_rows: 5, offset: 0, rows: [ { id: 'smokey', key: 3, value: null }, { id: 'tiger', key: 7, value: null }, { id: 'daisy', key: 9, value: null }, { id: 'mittens', key: 10, value: null }, { id: 'lily', key: 16, value: null } ] } @BradleyHolt
  • 24. Query a View with Start Key and End Key /kittens> @BradleyHolt
  • 25. Query a View with Start Key and End Key /kittens> GET /_design/kittens/_view/by_age?startkey=7&endkey=10 @BradleyHolt
  • 26. Query a View with Start Key and End Key /kittens> GET /_design/kittens/_view/by_age?startkey=7&endkey=10 HTTP/1.1 200 OK Content-Type: application/json { total_rows: 5, offset: 1, rows: [ { id: 'tiger', key: 7, value: null }, { id: 'daisy', key: 9, value: null }, { id: 'mittens', key: 10, value: null } ] } @BradleyHolt
  • 27. Add a Reduce Function /kittens> @BradleyHolt
  • 28. Add a Reduce Function /kittens> GET /_design/kittens @BradleyHolt
  • 29. Add a Reduce Function /kittens> GET /_design/kittens HTTP/1.1 200 OK Content-Type: application/json { _id: '_design/kittens', _rev: '1-c38a0039638b950f64e02c51fe2e9229', views: { by_age: { map: 'function(doc) { emit(doc.age_weeks) }' } } } @BradleyHolt
  • 30. Add a Reduce Function /kittens> @BradleyHolt
  • 31. Add a Reduce Function /kittens> PUT /_design/kittens?rev=1-c38a0039638b950f64e02c51fe2e9229 @BradleyHolt
  • 32. Add a Reduce Function /kittens> PUT /_design/kittens?rev=1-c38a0039638b950f64e02c51fe2e9229 ... { "views": { "by_age": { "map": "function(doc) { emit(doc.age_weeks, doc.weight_kilograms) }", "reduce": "_stats" } } } @BradleyHolt
  • 33. Add a Reduce Function /kittens> PUT /_design/kittens?rev=1-c38a0039638b950f64e02c51fe2e9229 ... { "views": { "by_age": { "map": "function(doc) { emit(doc.age_weeks, doc.weight_kilograms) }", "reduce": "_stats" } } } HTTP/1.1 201 Created Content-Type: application/json { ok: true, id: '_design/kittens', rev: '2-a64e3539068221e7b4eaa94917faed5f' } @BradleyHolt
  • 34. Query a View with a Reduce Function /kittens> @BradleyHolt
  • 35. Query a View with a Reduce Function /kittens> GET /_design/kittens/_view/by_age @BradleyHolt
  • 36. Query a View with a Reduce Function /kittens> GET /_design/kittens/_view/by_age HTTP/1.1 200 OK Content-Type: application/json { rows: [ { key: null, value: { sum: 4.8919999999999995, count: 5, min: 0.403, max: 1.95, sumsqr: 6.15185 } } ] } @BradleyHolt
  • 37. Try It On Your Own 1. Create an view of kittens by weight_kilograms, using age_weeks as the value and using a _stats reduce function 2. Find kittens weighing less than 1 kilogram (use the reduce=false parameter) 3. Find the stats of kittens weighing less than 1 kilogram @BradleyHolt
  • 38. Lab: Map/Reduce Views CouchDB Developer Day @BradleyHolt

Editor's Notes

  1. HTTP Basic authentication is a simple way to authenticate with an HTTP server Other approaches, such as cookies and OAuth, are often used as well