我似乎无法在图中找到特定节点而不遍历整个事物。有什么我想念的吗?
我正在使用tinkerpop蓝图。
Orientdb为某个节点提供某种非语义ID,例如“#8:1” - 如何在不知道ID的情况下找到它? vertex有一个像'user = jason'这样的属性来识别它。 我想我只会使用redis来存储用户/位置对或者使用超级节点(不,谢谢)
答案 0 :(得分:10)
蓝图具有关键指数的概念。
https://github.com/tinkerpop/blueprints/wiki/Graph-Indices
根据您的示例,为“user”定义键索引,然后使用键索引查询它。以下是使用Gremlin提示符中的OrientDB的示例:
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]