mongodb Aggregate on string length in MongoDB It's not actually possible to use the aggregation pipeline to aggregate on string length, at last in MongoDB 3.2 (the current version as of this writing). You may think that you can use the $size operator, but alas you'll end up with errors