title: Using pymongo, how do you find all documents, such that an embedded list in each document contains greater than X elements?
body: <p>I would like to run a find-query on MongoDB that searches over a set of documents in a collection, where each document contains a list of elements, and only return the documents in which the # of elements in the list is greater than X.</p>
  
  <p>This returns all documents where len(messages) == X:</p>
  
  <pre><code>db.log.find({'messages':{'$size':X}})
  </code></pre>
  
  <p>but how do I get all documents where len(messages) >= X ?</p>