Home Page Icon
Home Page
Table of Contents for
MongoDB: The Definitive Guide
Close
MongoDB: The Definitive Guide
by Michael Dirolf, Kristina Chodorow
MongoDB: The Definitive Guide
Foreword
Preface
How This Book Is Organized
Getting Up to Speed with MongoDB
Developing with MongoDB
Advanced Usage
Administration
Developing Applications with MongoDB
Appendixes
Conventions Used in This Book
Using Code Examples
Safari® Books Online
How to Contact Us
Acknowledgments
Acknowledgments from Kristina
Acknowledgments from Michael
1. Introduction
A Rich Data Model
Easy Scaling
Tons of Features…
…Without Sacrificing Speed
Simple Administration
But Wait, That’s Not All…
2. Getting Started
Documents
Collections
Schema-Free
Naming
Subcollections
Databases
Getting and Starting MongoDB
MongoDB Shell
Running the Shell
A MongoDB Client
Basic Operations with the Shell
Create
Read
Update
Delete
Tips for Using the Shell
Inconvenient collection names
Data Types
Basic Data Types
Numbers
Dates
Arrays
Embedded Documents
_id and ObjectIds
ObjectIds
Autogeneration of _id
3. Creating, Updating, and Deleting Documents
Inserting and Saving Documents
Batch Insert
Inserts: Internals and Implications
Removing Documents
Remove Speed
Updating Documents
Document Replacement
Using Modifiers
Getting started with the “$set” modifier
Incrementing and decrementing
Array modifiers
Positional array modifications
Modifier speed
Upserts
The save Shell Helper
Updating Multiple Documents
Returning Updated Documents
The Fastest Write This Side of Mississippi
Safe Operations
Catching “Normal” Errors
Requests and Connections
4. Querying
Introduction to find
Specifying Which Keys to Return
Limitations
Query Criteria
Query Conditionals
OR Queries
$not
Rules for Conditionals
Type-Specific Queries
null
Regular Expressions
Querying Arrays
$all
$size
The $slice operator
Querying on Embedded Documents
$where Queries
Cursors
Limits, Skips, and Sorts
Comparison order
Avoiding Large Skips
Paginating results without skip
Finding a random document
Advanced Query Options
Getting Consistent Results
Cursor Internals
5. Indexing
Introduction to Indexing
Scaling Indexes
Indexing Keys in Embedded Documents
Indexing for Sorts
Uniquely Identifying Indexes
Unique Indexes
Dropping Duplicates
Compound Unique Indexes
Using explain and hint
Index Administration
Changing Indexes
Geospatial Indexing
Compound Geospatial Indexes
The Earth Is Not a 2D Plane
6. Aggregation
count
distinct
group
Using a Finalizer
Using a Function as a Key
MapReduce
Example 1: Finding All Keys in a Collection
Example 2: Categorizing Web Pages
MongoDB and MapReduce
The finalize function
Keeping output collections
MapReduce on a subset of documents
Using a scope
Getting more output
7. Advanced Topics
Database Commands
How Commands Work
Command Reference
Capped Collections
Properties and Use Cases
Creating Capped Collections
Sorting Au Naturel
Tailable Cursors
GridFS: Storing Files
Getting Started with GridFS: mongofiles
Working with GridFS from the MongoDB Drivers
Under the Hood
Server-Side Scripting
db.eval
Stored JavaScript
Security
Database References
What Is a DBRef?
Example Schema
Driver Support for DBRefs
When Should DBRefs Be Used?
8. Administration
Starting and Stopping MongoDB
Starting from the Command Line
File-Based Configuration
Stopping MongoDB
Monitoring
Using the Admin Interface
serverStatus
mongostat
Third-Party Plug-Ins
Security and Authentication
Authentication Basics
How Authentication Works
Other Security Considerations
Backup and Repair
Data File Backup
mongodump and mongorestore
fsync and Lock
Slave Backups
Repair
9. Replication
Master-Slave Replication
Options
Adding and Removing Sources
Replica Sets
Initializing a Set
Nodes in a Replica Set
Failover and Primary Election
Performing Operations on a Slave
Read Scaling
Using Slaves for Data Processing
How It Works
The Oplog
Syncing
Replication State and the Local Database
Blocking for Replication
Administration
Diagnostics
Changing the Oplog Size
Replication with Authentication
10. Sharding
Introduction to Sharding
Autosharding in MongoDB
When to Shard
The Key to Sharding: Shard Keys
Sharding an Existing Collection
Incrementing Shard Keys Versus Random Shard Keys
How Shard Keys Affect Operations
Setting Up Sharding
Starting the Servers
Adding a shard
Sharding Data
Production Configuration
A Robust Config
Many mongos
A Sturdy Shard
Physical Servers
Sharding Administration
config Collections
Shards
Databases
Chunks
Sharding Commands
Getting a summary
Removing a shard
11. Example Applications
Chemical Search Engine: Java
Installing the Java Driver
Using the Java Driver
Schema Design
Writing This in Java
Issues
News Aggregator: PHP
Installing the PHP Driver
Windows install
Mac OS X Install
Linux and Unix install
Using the PHP Driver
Designing the News Aggregator
Trees of Comments
Voting
Custom Submission Forms: Ruby
Installing the Ruby Driver
Using the Ruby Driver
Custom Form Submission
Ruby Object Mappers and Using MongoDB with Rails
Real-Time Analytics: Python
Installing PyMongo
Using PyMongo
MongoDB for Real-Time Analytics
Schema
Handling a Request
Using Analytics Data
Other Considerations
A. Installing MongoDB
Choosing a Version
Windows Install
Installing as a Service
POSIX (Linux, Mac OS X, and Solaris) Install
Installing from a Package Manager
B. mongo: The Shell
Shell Utilities
C. MongoDB Internals
BSON
Wire Protocol
Data Files
Namespaces and Extents
Memory-Mapped Storage Engine
Index
About the Authors
Colophon
Copyright
Search in book...
Toggle Font Controls
Playlists
Add To
Create new playlist
Name your new playlist
Playlist description (optional)
Cancel
Create playlist
Sign In
Email address
Password
Forgot Password?
Create account
Login
or
Continue with Facebook
Continue with Google
Sign Up
Full Name
Email address
Confirm Email Address
Password
Login
Create account
or
Continue with Facebook
Continue with Google
Prev
Previous Chapter
O'Reilly Strata Conference
Next
Next Chapter
Foreword
MongoDB: The Definitive Guide
Kristina Chodorow
Michael Dirolf
Beijing • Cambridge • Farnham • Köln • Sebastopol • Tokyo
Add Highlight
No Comment
..................Content has been hidden....................
You can't read the all page of ebook, please click
here
login for view all page.
Day Mode
Cloud Mode
Night Mode
Reset