Preface |
|
xvii | |
Acknowledgments |
|
xix | |
About this book |
|
xxi | |
About the cover illustration |
|
xxiv | |
|
|
1 | (70) |
|
1 A database for the modern web |
|
|
3 | (26) |
|
1.1 Built for the internet |
|
|
5 | (1) |
|
1.2 MongoDB's key features |
|
|
6 | (9) |
|
|
6 | (4) |
|
|
10 | (1) |
|
|
10 | (1) |
|
|
11 | (1) |
|
|
12 | (2) |
|
|
14 | (1) |
|
1.3 MongoDB's core server and tools |
|
|
15 | (3) |
|
|
16 | (1) |
|
|
16 | (1) |
|
|
17 | (1) |
|
|
18 | (1) |
|
|
18 | (6) |
|
MongoDB versus other databases |
|
|
19 | (3) |
|
Use cases and production deployments |
|
|
22 | (2) |
|
|
24 | (1) |
|
|
25 | (2) |
|
|
27 | (1) |
|
|
28 | (1) |
|
2 MongoDB through the JavaScript shell |
|
|
29 | (23) |
|
2.1 Diving into the MongoDB shell |
|
|
30 | (9) |
|
|
30 | (1) |
|
Databases, collections, and documents |
|
|
31 | (1) |
|
|
32 | (2) |
|
|
34 | (4) |
|
|
38 | (1) |
|
|
38 | (1) |
|
2.2 Creating and querying with indexes |
|
|
39 | (7) |
|
Creating a large collection |
|
|
39 | (2) |
|
|
41 | (5) |
|
|
46 | (3) |
|
Getting database information |
|
|
46 | (2) |
|
|
48 | (1) |
|
|
49 | (2) |
|
|
51 | (1) |
|
3 Writing programs using MongoDB |
|
|
52 | (19) |
|
3.1 MongoDB through the Ruby lens |
|
|
53 | (6) |
|
Installing and connecting |
|
|
53 | (2) |
|
Inserting documents in Ruby |
|
|
55 | (1) |
|
|
56 | (1) |
|
|
57 | (1) |
|
|
58 | (1) |
|
|
59 | (2) |
|
|
59 | (2) |
|
3.3 Building a simple application |
|
|
61 | (8) |
|
|
61 | (1) |
|
|
62 | (3) |
|
|
65 | (4) |
|
|
69 | (2) |
|
PART 2 APPLICATION DEVELOPMENT IN MONGODB |
|
|
71 | (124) |
|
|
73 | (25) |
|
4.1 Principles of schema design |
|
|
74 | (1) |
|
4.2 Designing an e-commerce data model |
|
|
75 | (9) |
|
|
76 | (4) |
|
|
80 | (3) |
|
|
83 | (1) |
|
4.3 Nuts and bolts: On databases, collections, and documents |
|
|
84 | (12) |
|
|
84 | (3) |
|
|
87 | (5) |
|
|
92 | (4) |
|
|
96 | (2) |
|
|
98 | (22) |
|
|
99 | (4) |
|
Products, categories, and reviews |
|
|
99 | (2) |
|
|
101 | (2) |
|
5.2 MongoDB's query language |
|
|
103 | (16) |
|
Query criteria and selectors |
|
|
103 | (14) |
|
|
117 | (2) |
|
|
119 | (1) |
|
|
120 | (37) |
|
6.1 Aggregation framework overview |
|
|
121 | (2) |
|
6.2 E-commerce aggregation example |
|
|
123 | (12) |
|
Products, categories, and reviews |
|
|
125 | (7) |
|
|
132 | (3) |
|
6.3 Aggregation pipeline operators |
|
|
135 | (5) |
|
|
136 | (1) |
|
|
136 | (2) |
|
$match, $sort, $skip, $limit |
|
|
138 | (1) |
|
|
139 | (1) |
|
|
139 | (1) |
|
|
140 | (6) |
|
|
141 | (1) |
|
|
142 | (1) |
|
|
142 | (1) |
|
|
143 | (1) |
|
|
144 | (1) |
|
|
145 | (1) |
|
6.5 Understanding aggregation pipeline performance |
|
|
146 | (6) |
|
Aggregation pipeline options |
|
|
147 | (1) |
|
The aggregation framework's explain( ) function |
|
|
147 | (4) |
|
|
151 | (1) |
|
Aggregation cursor option |
|
|
151 | (1) |
|
6.6 Other aggregation capabilities |
|
|
152 | (4) |
|
.count( ) and distinct( ) |
|
|
153 | (1) |
|
|
153 | (3) |
|
|
156 | (1) |
|
7 Updates, atomic operations, and deletes |
|
|
157 | (38) |
|
7.1 A brief tour of document updates |
|
|
158 | (4) |
|
|
159 | (1) |
|
|
159 | (1) |
|
|
160 | (1) |
|
Deciding: replacement vs. operators |
|
|
160 | (2) |
|
|
162 | (9) |
|
|
162 | (5) |
|
|
167 | (1) |
|
|
168 | (3) |
|
7.3 Atomic document processing |
|
|
171 | (8) |
|
|
172 | (2) |
|
|
174 | (5) |
|
7.4 Nuts and bolts: MongoDB updates and deletes |
|
|
179 | (13) |
|
|
179 | (2) |
|
|
181 | (7) |
|
The findAndModify command |
|
|
188 | (1) |
|
|
189 | (1) |
|
Concurrency, atomicity, and isolation |
|
|
190 | (1) |
|
|
191 | (1) |
|
7.5 Reviewing update operators |
|
|
192 | (1) |
|
|
193 | (2) |
|
|
195 | (216) |
|
8 Indexing and query optimization |
|
|
197 | (47) |
|
|
198 | (9) |
|
|
198 | (3) |
|
|
201 | (4) |
|
|
205 | (2) |
|
|
207 | (9) |
|
|
207 | (4) |
|
|
211 | (5) |
|
|
216 | (27) |
|
|
217 | (4) |
|
|
221 | (20) |
|
|
241 | (2) |
|
|
243 | (1) |
|
|
244 | (29) |
|
9.1 Text searches---not just pattern matching |
|
|
245 | (8) |
|
Text searches vs. pattern matching |
|
|
246 | (1) |
|
Text searches vs. web page searches |
|
|
247 | (3) |
|
MongoDB text search vs. dedicated text search engines |
|
|
250 | (3) |
|
9.2 Manning book catalog data download |
|
|
253 | (2) |
|
9.3 Defining text search indexes |
|
|
255 | (2) |
|
|
255 | (1) |
|
Assigning an index name and indexing all text fields in a collection |
|
|
256 | (1) |
|
|
257 | (6) |
|
|
259 | (2) |
|
|
261 | (1) |
|
Sorting results by text search score |
|
|
262 | (1) |
|
9.5 Aggregation framework text search |
|
|
263 | (4) |
|
Where's MongoDB in Action, Second Edition? |
|
|
265 | (2) |
|
9.6 Text search languages |
|
|
267 | (5) |
|
Specifying language in the index |
|
|
267 | (2) |
|
Specifying the language in the document |
|
|
269 | (1) |
|
Specifying the language in a search |
|
|
269 | (2) |
|
|
271 | (1) |
|
|
272 | (1) |
|
10 WiredTiger and pluggable storage |
|
|
273 | (23) |
|
10.1 Pluggable Storage Engine API |
|
|
273 | (2) |
|
Why use different storages engines? |
|
|
274 | (1) |
|
|
275 | (3) |
|
|
276 | (1) |
|
Migrating your database to WiredTiger |
|
|
277 | (1) |
|
10.3 Comparison with MMAPvl |
|
|
278 | (11) |
|
|
279 | (2) |
|
Insertion script and benchmark script |
|
|
281 | (2) |
|
Insertion benchmark results |
|
|
283 | (2) |
|
|
285 | (1) |
|
|
286 | (2) |
|
|
288 | (1) |
|
10.4 Other examples of pluggable storage engines |
|
|
289 | (1) |
|
|
290 | (5) |
|
How does a pluggable storage engine work? |
|
|
290 | (2) |
|
|
292 | (2) |
|
|
294 | (1) |
|
|
295 | (1) |
|
|
296 | (37) |
|
11.1 Replication overview |
|
|
297 | (3) |
|
|
297 | (1) |
|
Replication use cases and limitations |
|
|
298 | (2) |
|
|
300 | (24) |
|
|
300 | (7) |
|
|
307 | (7) |
|
|
314 | (10) |
|
11.3 Drivers and replication |
|
|
324 | (8) |
|
|
324 | (3) |
|
|
327 | (1) |
|
|
328 | (2) |
|
|
330 | (2) |
|
|
332 | (1) |
|
12 Scaling your system with sharding |
|
|
333 | (43) |
|
|
334 | (2) |
|
|
334 | (1) |
|
|
335 | (1) |
|
12.2 Understanding components of a sharded cluster |
|
|
336 | (3) |
|
Shards: storage of application data |
|
|
337 | (1) |
|
Mongos router: router of operations |
|
|
338 | (1) |
|
Config servers: storage of metadata |
|
|
338 | (1) |
|
12.3 Distributing data in a sharded cluster |
|
|
339 | (4) |
|
Ways data can be distributed in a sharded cluster |
|
|
340 | (1) |
|
Distributing databases to shards |
|
|
341 | (1) |
|
Sharding within collections |
|
|
341 | (2) |
|
12.4 Building a sample shard cluster |
|
|
343 | (12) |
|
Starting the mongod and mongos servers |
|
|
343 | (3) |
|
|
346 | (1) |
|
|
347 | (2) |
|
Writing to a sharded cluster |
|
|
349 | (6) |
|
12.5 Querying and indexing a shard cluster |
|
|
355 | (4) |
|
|
355 | (1) |
|
Indexing in a sharded cluster |
|
|
356 | (1) |
|
The explain() tool in a sharded cluster |
|
|
357 | (2) |
|
Aggregation in a sharded cluster |
|
|
359 | (1) |
|
12.6 Choosing a shard key |
|
|
359 | (6) |
|
Imbalanced writes (hotspots) |
|
|
360 | (2) |
|
Unsplittable chunks (coarse granularity) |
|
|
362 | (1) |
|
Poor targeting (shard key not present in queries) |
|
|
362 | (1) |
|
|
363 | (1) |
|
Inherent design trade-offs (email application) |
|
|
364 | (1) |
|
12.7 Sharding in production |
|
|
365 | (10) |
|
|
366 | (3) |
|
|
369 | (1) |
|
|
370 | (5) |
|
|
375 | (1) |
|
13 Deployment and administration |
|
|
376 | (35) |
|
13.1 Hardware and provisioning |
|
|
377 | (9) |
|
|
377 | (1) |
|
|
378 | (7) |
|
|
385 | (1) |
|
13.2 Monitoring and diagnostics |
|
|
386 | (5) |
|
|
387 | (1) |
|
MongoDB diagnostic commands |
|
|
387 | (1) |
|
|
388 | (2) |
|
MongoDB Monitoring Service |
|
|
390 | (1) |
|
External monitoring applications |
|
|
390 | (1) |
|
|
391 | (3) |
|
Mongodump and mongorestore |
|
|
391 | (1) |
|
|
392 | (1) |
|
|
393 | (1) |
|
|
394 | (8) |
|
|
394 | (1) |
|
|
395 | (2) |
|
|
397 | (4) |
|
Replica set authentication |
|
|
401 | (1) |
|
|
402 | (1) |
|
Enterprise security features |
|
|
402 | (1) |
|
13.5 Administrative tasks |
|
|
402 | (3) |
|
|
402 | (1) |
|
|
403 | (2) |
|
|
405 | (1) |
|
13.6 Performance troubleshooting |
|
|
405 | (3) |
|
|
406 | (1) |
|
|
407 | (1) |
|
|
407 | (1) |
|
Seek professional assistance |
|
|
408 | (1) |
|
13.7 Deployment checklist |
|
|
408 | (2) |
|
|
410 | (1) |
Appendix A Installation |
|
411 | (10) |
Appendix B Design patterns |
|
421 | (12) |
Appendix C Binary data and GridFS |
|
433 | (8) |
Index |
|
441 | |