title: Filtering embedded documents in MongoDB
body: <p>I am having trouble grasping how to filter embedded documents in MongoDB, and am starting to think I should be using a relational association, but that feels wrong in the document-store context.</p>
  
  <p>Sticking with a typical blog/comment system, I have a collection of <code>blogs</code>, and each <code>blog</code> has many <code>comments</code>.  The comments are stored as embedded documents inside the blog document.</p>
  
  <p>It is very simple to filter my <code>blogs</code> collection, but in order to filter my <code>comments</code> embedded in each <code>blog</code>, I am having to load them all into memory (retrieve all into a Ruby array), and loop through each comment, returning ones that match a specific criteria.</p>
  
  <p>My efforts to filter embedded documents using dot notation is failing, and bringing back all sub documents.</p>
  
  <p>Is there a better way of getting MongoDB to filter these for me, or should I resign myself to relational associations? (Pulling back all embedded documents and manually filtering is going to be too intensive in the long run)</p>