0

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()
  • @kelvin: when i use [from gremlin_python.process.traversal import P] I ended up getting exception '{TypeError}an integer is required (got type str)'. – Gowtham Ravichandran Oct 08 '21 at 01:59

1 Answers1

1

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)]}
Kelvin Lawrence
  • 14,674
  • 2
  • 16
  • 38