Tips for working with the MongoDB aggregation framework

  1. Review the data.
    What are the data types? What is the structure? What do the values mean?
  2. Build out the query one stage at a time.
  3. Start with one pipeline operation and a limit operation at the end. Review that you are getting the results you expect. Keep the limit operation in place as you add operations. Verify expected behavior every step of the way.
  4. Remove the limit operation as the last step .
The online documentation will be very useful:
http://docs.mongodb.org/manual/aggregation/

http://docs.mongodb.org/manual/core/aggregation-pipeline/
http://docs.mongodb.org/manual/reference/operator/aggregation/


This reference includes some nice material regarding comparison with standard SQL operations: http://docs.mongodb.org/manual/reference/sql-aggregation-comparison/

No comments:

Post a Comment