Hello. Im unable to understand the results talked about in the post below. The graphlookup query matches the destination airport of Route X with source airports for all other available routes. However, if you look at the results of this query for the document with objectid 56e9b39c732b6122f878b0cc, the very first result going from ORY to IBZ does not match with its predecessor route going from AKL to BNE.
To be doubly sure of my interpretation, I created a sample db with the below data.
| id | Dst| Src|
| 1 | A | C |
| 2 | C | F |
| 3 | F | M |
| 4 | F | B |
| 5 | M | G |
| 6 | G | Y |
| 7 | Y | B |
| 8 | H | I |
| 9 | I | J |
| 10 | J | K |
And ran the below query:
db.Test2.aggregate( [{
$graphLookup: {
from: "Test2",
startWith: "$Src",
connectFromField: : "Src",
connectToField: "Dst",
as: "reportingHierarchy"
}
}] )
Results from this query for id 1 below:
{
"_id":ObjectId(“62630a7aca44907f39e62a44”),
"id":6,
"Dst":"G",
"Src":"Y"
},
{
"_id":ObjectId(“62630a7aca44907f39e62a43”),
"id":5,
"Dst":"M",
"Src":"G"
},
{
"_id":ObjectId(“62630a7aca44907f39e62a45”),
"id":7,
"Dst":"Y",
"Src":"B"
},
{
"_id":ObjectId(“62630a7aca44907f39e62a41”),
"id":3,
"Dst":"F",
"Src":"M"
},
{
"_id":ObjectId(“62630a7aca44907f39e62a42”),
"id":4,
"Dst":"F",
"Src":"B"
}
]
}
ABOUT
Ideally, this query should give the below result for id1: id 2-3-5-6-7 and id 2-4. How do I make sense of these results, the query seems to be traversing my documents and reporting results in an order that doesn’t seem to make sense.