Suppose I have:
Order: {_id: ..., items: [...]}
How to filter orders which have item number greater than 5?
You cann't query by size of embed collection, you need to create field with size of collection for such needs(mongo db documentation):
The $size operator matches any array with the specified number of elements. The following example would match the object {a:["foo"]}, since that array has just one element:
db.things.find( { a : { $size: 1 } } );
You cannot use $size to find a range of sizes (for example: arrays with more than 1 element). If you need to query for a range, create an extra size field that you increment when you add elements.