I am new to MongoDB – just trying to learn it – not new to Java/SQL though. Suppose I have a shopping cart application developed in Java/MongoDB. Further suppose I have a document Order.java. So Order keeps usual order properties: Total amount, shipping address, credit card number and etc. as well as collection of line items. Now since order line items are part of order document they cannot be accesses individually without retrieving entire order. Right?  

What I want it to show something like what Amazon does when you view a book: "People who bought this book – also bought so-and-so book". How do I determine that in MongoDB/Java application? In SQL it would be more or less simple query joining OrderLineItem to itself, or something along these lines, but there no joins in MongoDB. Should I load all Order documents into Java app, and then sort and match them in Java (essentially in memory). That does not seem practical if talking about millions of orders, is there anything else I can do?