ts1=graph.addVertex(label,"test","test_id",872)
ts2=graph.addVertex(label,"test","test_id",873)
rj1=graph.addVertex(label,"req","id1",113,"status","S")
rj2=graph.addVertex(label,"req","id1",114,"status","S")
e1=rj1.addEdge("edgeA",ts1,"seq",1)
e2=rj2.addEdge("edgeA",ts2,"seq",2)
我能够在单独的查询中获得以下内容:
g.V().hasLabel("req").has("status","S").outE("edgeA").valueMap()
==>[seq:1]
==>[seq:2]
g.V().hasLabel("job").has("status","S").outE("job_edge").inV().valueMap()
==>[test_id,872]
==>[test_id,873]
如何在单个查询中获取序列和相应的test_id
更新的问题:
public void readTestbedJob(String tbName){
GraphTraversalSource traversalSource = getTitanTraversalSource();
GraphTraversal<Vertex, Map<String, Object>> query1 = traversalSource.V()
.has("req","id1",113).valueMap();
GraphTraversal<Vertex, Map<String, Object>> query2 = traversalSource.V().has("status","S").as("a").
outE("edgeA").as("e").
inV().as("v").
select("a","e","v").by(valueMap());
}
从gremlin控制台:query1和query2都正确返回结果。
但是,我无法直接在java中使用query2中的valueMap()或values(),
GraphTraversal<Vertex, Map<String, Object>> query2 = traversalSource.V().has("status","S").as("a").
outE("edgeA").as("e").
inV().as("v").
select("a","e","v").by(valueMap());
1)当我在上面的查询中直接使用(valueMap())或(values())时,我得到以下编译错误:undefined function valueMap()
2)而不是通过(valueMap()),by()只返回顶点id和边缘id。
a = v [16576],b = e [2pjpce-6eo-90r9-9ig] [edgeA],c = v [8304]}
你能帮我解决这个问题吗?我无法在Java中识别如何使用(valueMap())。
答案 0 :(得分:3)
您可以使用select()
:
gremlin> g.V().has("job_status","S").
......1> outE("edgeA").as('e').
......2> inV().as('v').
......3> select('e','v').by(valueMap())
==>[e:[sequence:1],v:[test_suite_id:[872]]]
==>[e:[sequence:2],v:[test_suite_id:[873]]]