title: Is there a way to use the graphLookup aggregation pipeline stage for arrays?
body: <p>I am currently working on an application that uses MongoDB as the data repository. I am mainly concerned about the graphLookup query to establish links between different people, based on what flights they took. My document contains an array field, that in turn contains key value pairs. I need to establish the links based on one of the key:value pairs of that array.</p>
  
  <p>I have already tried some queries of aggregation pipeline with $graphLookup as one of the stages and they have all worked fine. But now that I am trying to use it with an array, I am hitting a blank. </p>
  
  <p>Below is the array field from the first document :</p>
  
  <pre><code>"movementSegments":[  
        {  
           "carrierCode":"MO269",
           "departureDateTimeMillis":1550932676000,
           "arrivalDateTimeMillis":1551019076000,
           "departurePort":"DOH",
           "arrivalPort":"LHR",
           "departurePortText":"HAMAD INTERNATIONAL AIRPORT",
           "arrivalPortText":"LONDON HEATHROW",
           "serviceNameText":"",
           "serviceKey":"BA007_1550932676000",
           "departurePortLatLong":"25.273056,51.608056",
           "arrivalPortLatLong":"51.4706,-0.461941",
           "departureWeeklyTemporalSpatialWindow":"DOH_8",
           "departureMonthlyTemporalSpatialWindow":"DOH_2",
           "arrivalWeeklyTemporalSpatialWindow":"LHR_8",
           "arrivalMonthlyTemporalSpatialWindow":"LHR_2"
        }
     ]
  </code></pre>
  
  <p>The other document has the below field :</p>
  
  <pre><code>"movementSegments":[  
        {  
           "carrierCode":"MO269",
           "departureDateTimeMillis":1548254276000,
           "arrivalDateTimeMillis":1548340676000,
           "departurePort":"DOH",
           "arrivalPort":"LHR",
           "departurePortText":"HAMAD INTERNATIONAL AIRPORT",
           "arrivalPortText":"LONDON HEATHROW",
           "serviceNameText":"",
           "serviceKey":"BA003_1548254276000",
           "departurePortLatLong":"25.273056,51.608056",
           "arrivalPortLatLong":"51.4706,-0.461941",
           "departureWeeklyTemporalSpatialWindow":"DOH_4",
           "departureMonthlyTemporalSpatialWindow":"DOH_1",
           "arrivalWeeklyTemporalSpatialWindow":"LHR_4",
           "arrivalMonthlyTemporalSpatialWindow":"LHR_1"
        },
        {  
           "carrierCode":"MO270",
           "departureDateTimeMillis":1548254276000,
           "arrivalDateTimeMillis":1548340676000,
           "departurePort":"DOH",
           "arrivalPort":"LHR",
           "departurePortText":"HAMAD INTERNATIONAL AIRPORT",
           "arrivalPortText":"LONDON HEATHROW",
           "serviceNameText":"",
           "serviceKey":"BA003_1548254276000",
           "departurePortLatLong":"25.273056,51.608056",
           "arrivalPortLatLong":"51.4706,-0.461941",
           "departureWeeklyTemporalSpatialWindow":"DOH_4",
           "departureMonthlyTemporalSpatialWindow":"DOH_1",
           "arrivalWeeklyTemporalSpatialWindow":"LHR_4",
           "arrivalMonthlyTemporalSpatialWindow":"LHR_1"
        }
     ]
  </code></pre>
  
  <p>And I am running the below query :</p>
  
  <pre><code>db.person_events.aggregate([
    { $match: { eventId: "22446688" } },
    {
      $graphLookup: {
        from: 'person_events',
        startWith: '$movementSegments.carrierCode',
        connectFromField: 'carrierCode',
        connectToField: 'carrierCode',
        as: 'carrier_connections'
      }
    }
    ])
  </code></pre>
  
  <p>The above query creates an array field in the document, but there are no values in it. As per the expectation, both my documents should get linked based on the carrier number.
  Just to be clear about the query, the documents contain an eventId field, and the match pipeline returns one document to me after the match stage.</p>