Reputation: 11
I want to filter the vertex based out of a date. I don't know from which package i have to refer the gt
graph = Graph()
remote_connection = DriverRemoteConnection(gremlin, 'g')
g = graph.traversal().withRemote(remote_connection)
serviceAcc=g.V().hasLabel('ServiceAccount').has('creationTime',TextP.gt(datetime.datetime('2021-10-05'))).valueMap(True).toList()
remote_connection.close()
Upvotes: 0
Views: 489
Reputation: 14391
The predicates like gt
and lt
are part of the P
class. So you would use P.gt
.
UPDATED to show an example on 2021-10-26
Using the Python console connected to a Gremlin server (Amazon Neptune in this case)
>>> import datetime
>>> g.addV('now').property('date',datetime.datetime(2021,10,25,19,41,0)).next()
v[3ebe5ef4-512a-a2e1-e519-34583b96dd1c]
>>> g.V().has('date',P.gte(datetime.datetime(2021,10,25,19,0,0))).next()
v[3ebe5ef4-512a-a2e1-e519-34583b96dd1c]
>>> g.V().has('date',P.gte(datetime.datetime(2021,10,25,19,0,0))).valueMap().next()
{'date': [datetime.datetime(2021, 10, 25, 19, 41)]}
Upvotes: 1