title: Spring Data MongoDB Lookup with Pipeline Aggregation
body: <p>How would I convert the following MongoDB query into a query to be used by my Java Spring application? I can't find a way to use <code>pipeline</code> with the provided <a href="https://docs.spring.io/spring-data/data-mongo/docs/current/api/org/springframework/data/mongodb/core/aggregation/LookupOperation.html" rel="noreferrer">lookup</a> method.</p>
  
  <p>Here is the query I am attempting to convert. I also want to note that I didn't use <code>$unwind</code> as I wanted the <code>deliveryZipCodeTimings</code> to stay as a grouped collection in the return object.</p>
  
  <pre><code>db.getCollection('fulfillmentChannel').aggregate([
      {
          $match: {
              "dayOfWeek": "SOME_VARIABLE_STRING_1"
          }
      },
      {
          $lookup: {
              from: "deliveryZipCodeTiming",
              let: { location_id: "$fulfillmentLocationId" },
              pipeline: [{
                  $match: {
                      $expr: {
                          $and: [
                              {$eq: ["$fulfillmentLocationId", "$$location_id"]},
                              {$eq: ["$zipCode", "SOME_VARIABLE_STRING_2"]}
                          ]
                      }
                  }
              },
              { 
                  $project: { _id: 0, zipCode: 1, cutoffTime: 1 } 
              }],
              as: "deliveryZipCodeTimings"
          }
      },
      {
          $match: {
              "deliveryZipCodeTimings": {$ne: []}
          }
      }
  ])
  </code></pre>