davebshow / goblin

A Python 3.5 rewrite of the TinkerPop 3 OGM Goblin
Other
93 stars 21 forks source link

How to use mixed index in goblin? #95

Open StanYaha opened 6 years ago

StanYaha commented 6 years ago

Hi,Dave. In gremlin shell, i use the composite index like this

g.V().has('id_number', 'xxx').toList()

I can use the goblin like

suspector = await session.traversal(Suspector).has('id_number', 'xxx').toList()

But how can i use the mixed index with goblin? In gremlin shell

g.V().has('age', inside(18,30)).toList()

How can i use the goblin to make this?

davebshow commented 6 years ago

Are you asking how to use inside?

from gremlin_python.process.traversal import inside

await session.g.V().has('age', inside(18,30)).toList()
davebshow commented 6 years ago

Did this solution work for you?

StanYaha commented 6 years ago

It's not worked!

async def go(loop):
    start = time.time()
    remote_connection = await DriverRemoteConnection.open('ws://localhost:8182/gremlin', 'g')
    g = Graph().traversal().withRemote(remote_connection)
    a = int(1516999699)
    b = int(1517492274)
    vertices =  await g.V().has('datetime',inside(a,b)).toList()

image

StanYaha commented 6 years ago
>>> from gremlin_python.process.traversal import inside
>>> from gremlin_python import statics
>>> from gremlin_python.structure.graph import Graph
>>> from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection
>>> statics.load_statics(globals())
>>> graph = Graph()
>>> g = graph.traversal().withRemote(DriverRemoteConnection('ws://localhost:8182','g'))
>>> g.V().has('datetime', inside(1516999699,1517492274)).toList()

This worked!But when i use the async and await,it failed