© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Apache TinkerPopAT
Apache TinkerPop•3y ago•
19 replies
terrabl

Getting Property Out of a Variable in Python Gremlin Query

I've been working on attempting to find a performance way to route from point A to point B.

Right now my schema is as follows

Vertex Labels:
1. Airport:
- Properties: airport: Airport code.
2. Day:
- Properties: Datestamp representing the day.

Edge Labels:
1. has_flights_on:
- Connects Airport to Day.
- Indicates an airport has flights on a specific day.
2. flight:
- Connects Day to Airport (destination).
- Properties: flight_id, origin, destination, start_timestamp, end_timestamp, capacity, tail_number, equipment_type.

Graph Structure:
- Airport vertex for each airport.
- Day vertex for specific days connected to airports with flights.
- has_flights_on edges connect Airport to Day.
- flight edges connect Day to Airport, representing flights.

Example:
- Airport (JFK) -> has_flightson -> Day (2023-08-03) -> flight -> Airport (LAX)
- Indicates a flight from JFK to LAX on August 3, 2023.

This is my query right now

```
g.V().has('Airport', 'airport', origin) # find origin airport
.as
('current_airport')
.repeat(
.out('has_flights_on') # Go to the corresponding Day vertex
.has('date', gte(start_datestamp))
.has('date', lte(end_datestamp))
.outE('flight') # Go to the Flight edge .where(
.values('origin').is_(.select('currentairport').values('airport'))) # this is the problem
.inV().hasLabel('Airport') # Go to the destination Airport vertex
.as
('current_airport') # Update the current airport alias
.simplePath() # Ensure that the path doesn't contain cycles
)
.until(
.has('airport', destination).or().loops().is(4)) # Finish when destination is reached or max hops exceeded
.has('airport', destination)
.path()
.by(__.valueMap('airport', 'flight_id', 'start_timestamp', 'end_timestamp'))
.toList()
```

The problem is the where, see below for more context.
Apache TinkerPop banner
Apache TinkerPopJoin
Apache TinkerPop is an open source graph computing framework and the home of the Gremlin graph query language.
1,376Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Solved: Gremlin Python Exceptions with .property("timeStamp", 0)
Apache TinkerPopATApache TinkerPop / questions
3y ago
Setting index in gremlin-python
Apache TinkerPopATApache TinkerPop / questions
2y ago
Query if else in gremlin
Apache TinkerPopATApache TinkerPop / questions
3y ago
Help with a gremlin query..
Apache TinkerPopATApache TinkerPop / questions
6mo ago