title: Multiply using Aggregates Class in Mongo DB
body: <p>So, I'm using MongoDB on Java via Maven and the Aggregation Framework for the selects. I have this document on the collection orders:</p>
  
  <pre><code>{ 
        "_id" : "orderKey0", 
        "orderdate" : 3, 
        "shippriority" : 0, 
        "customer" : { 
            "nationKey" : "nationKey0", 
            "mktsegment" : "mktsegment0" 
         }, 
        "lineitems" : { 
            "suppkey" : "suppkey1", 
            "quantity" : 9, 
            "extendedPrice" : 45, 
            "discount" : 18, 
            "tax" : 0, 
            "returnflag" : "b", 
            "linestatus" : "c", 
            "shipdate" : 4, 
            "shipingdate" : 1 
         } 
     }
  </code></pre>
  
  <p>I need to do this select:</p>
  
  <pre><code>SELECT sum(quantity) as sum_qty,
  sum(extendedprice) as sum_base_price, sum(l_extendedprice*(1-l_discount)) as
  sum_disc_price
  FROM *
  WHERE shipdate &lt;= '[date]'
  GROUP BY returnflag, linestatus
  </code></pre>
  
  <p>I don't know how to multiply and substract using the Aggregates class, any idea? I'm really blocked :S
  Note I have a more documents in the collections for the use of the group by.
  This is what I have done with the Aggregation Framework.</p>
  
  <pre><code>MongoCollection&lt;Document&gt; ordersCollection = database.getCollection("orders");
  
  ordersCollection.aggregate(
                      Arrays.asList(
                              Aggregates.unwind("$lineitems"),
                              Aggregates.match(Filters.lte("lineitems.shipdate", 10)),
                              Aggregates.group("$lineitems.linestatus",
                                      Accumulators.sum("sum_qty", "$lineitems.quantity"),
                                      Accumulators.sum("sum_base_price", "$lineitems.extendedPrice"))
                      )
              ).forEach(printBlock);
  </code></pre>