How can I use a subquery to translate airport code DAL into icao airport code KDAL, w air-routes?

I've loaded the air-routes data set, and I've added an aircraft like so: g.addV("aircraft").property("aircraftLocation", "DAL")

I want to write a query that reports the location of all my aircrafts like so: [tailNumber:N12345,aircraftLocationIcao:KDAL]

To accomplish this, I need to translate the IATA aircraft location "DAL" into the ICAO aircraft location "KDAL". So the .project() step is not straightforward.

#This query doesn't work because it yields the three letter IATA airport code instead of the four letter ICAO airport code
gremlin> g.V().hasLabel("aircraft").project("tailNumber", "aircraftLocationIcao").by("tailNumber").by("aircraftLocation")
==>[tailNumber:N12345,aircraftLocationIcao:DAL]


How can I accomplish this? Details of what I've already tried in thread: 🧵
Solution
Hi @danielcraig23, I might try to search for the the specific airports with the necessary iata->icao mapping instead of the "cross join then filter" approach. This is the traversal I came up with:
g.V().
  hasLabel("aircraft").as("ac").
  values("aircraftLocation").as("iata").
  select("ac").
  project("tailNumber", "aircraftLocationIcao").
    by("tailNumber").
    by(
      V().
      hasLabel("airport").
      where(values("code").where(eq('iata'))).
      values("icao"))


In my very small scale testing I'm seeing this run about an order of magnitude faster than the "cross join then filter" approach.
Was this page helpful?