Skip to Content
Developing with Couchbase Server
book

Developing with Couchbase Server

by MC Brown
February 2013
Intermediate to advanced
88 pages
2h 7m
English
O'Reilly Media, Inc.
Content preview from Developing with Couchbase Server

Chapter 6. Views and Queries

Once you’ve got your data into Couchbase Server, and you’ve thought about how you might model and represent the different parts of your information, you want to start pulling that information out again. Selecting the information by knowing the document ID will only get you so far.

Looking back at our recipe data, some frequent questions that might be asked are:

  • I’ve got carrots in my fridge, what can I do with them?

  • My bus leaves in 30 minutes, what I can cook in 20 minutes?

Or for the really fussy eaters:

  • I’ve got carrots and 20 minutes, what do I do?

These are not uncommon questions or perspectives on your data, and shouldn’t be unfamiliar concepts to any database user. But how do you translate your requirements from the data that we have stored into the list of recipes that match our selection?

The process that handles that is called the view. One or more views are used to process the stored documents and, in the process, create indexes. The view creates a structure that can be used to query and select information from the bucket by making use of the index structures you define.

Creating Views on Your Data

The principles of map/reduce within Couchbase are very simple. In order to query the documents in your database (rather than just access them by their ID), you have to create a view. The view contains the definition for two functions, map and reduce. The map function is required, and it defines the output format and contents of the view. ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Getting Started with Couchbase Server

Getting Started with Couchbase Server

MC Brown
Pro Couchbase Server, Second Edition

Pro Couchbase Server, Second Edition

David Ostrovsky, Mohammed Haji, Yaniv Rodenski
Couchbase Essentials

Couchbase Essentials

John C Zablocki

Publisher Resources

ISBN: 9781449331153Errata Page