View on GitHub

Cloudant Open Data

Collection of datasets that are easily available for your convenience via Cloudant APIs

Download this project as a .zip file Download this project as a tar.gz file

available databases

businesses_sf

sf_pd_incidents

opd_combined

ca_pub_schools

cal_doj_arrests

Interacting With A Sample Database

To help you become familiar with how to make use of a database managed by Cloudant, we should take a look at some sample queries. The goal here is to get an idea of what is possible when using a Cloudant database, and the power that comes along with exploring its various API options and built-in MapReduce capability.

Lets start by taking a look at one of the public datasets provided in open-data.

For all of the examples in this tutorial we'll be working with opd_combined, a database of incident reports made by the Oakland Police Department in the last 3 months which can be queried at https://open-data.cloudant.com/opd_combined

Reordering Data

Using views that can be generated through MapReduce, you can easily reorder the data in your dataset based on any key-value pair you specify.

For example, let's say I'm looking through the opd database and I'm generally interested in what types of offenses are being committed in Oakland.

To view my data in a way that reorders incidents based on the type of offense committed, I define a MapReduce function I call by_type that creates a new "view" of my data that treats the value of the "CType" (crime type) field in each document as a key, and emits each document as the value corresponding to this key. Whenever you want to query a specific view all you have to do is query the view you create at the _design endpoint of your database as in the following example.

curl 'https://open-data.cloudant.com/opd_combined/_design/by_type/_view/by_type?reduce=false&limit=100'

Note how the query parameters ?reduce=false&limit=100 are included; Cloudant supports API options for querying a database that can prove to be very useful in filtering the output you get back from any given query. These options include:

Useful Resources