Tinkerpop - how to find a node in a graph?

I can't find a specific node in the graph without going through all this. Is there something I am missing?

I am using tinkerpop blueprints.

Orientdb gives some kind of unearthly id for a node like "# 8: 1" - how can I find this without knowing the id? vertex has a property like "user = jason" that identifies it. I think I am just using redis to store user / location pair or otherwise use supernode (no thanks)

+3


source to share


1 answer


Blueprints have the concept of key indicators.

https://github.com/tinkerpop/blueprints/wiki/Graph-Indices



As per your example, define a key index for "user" and then query it using the key index. Here's an example using OrientDB from Gremlin's invitation:

gremlin> g = new OrientGraph("memory://graph")
==>orientgraph[memory://graph]
gremlin> g.createKeyIndex("user", Vertex.class)
==>null
gremlin> g.addVertex([user:"Jason"])
==>v[#8:-3]
gremlin> g.addVertex([user:"Rick"])
==>v[#8:-4]
gremlin> g.stopTransaction(SUCCESS)
==>null
gremlin> g.V('user','Jason')
==>v[#8:1]

      

+10


source







All Articles