【发布时间】:2015-10-28 18:58:51
【问题描述】:
我有两个疑问:
我以一种方法运行此查询
String query = "MATCH (g:Grid {name:'"+gridLocation+"'})<-[r:WILL_GO]-(t:Taxi)"
+ "WHERE r.reachedTime <= '"+userPickUp+"' RETURN t.name AS Taxi";
Result taxiWillGo = graphDb.execute(query);
另外一种方法
String query2 = "MATCH p=((g:Grid {name:'"+gridLocation+"'})-[r:TO*1..2]-(g2:Grid)), (g2)-[r2:LOCATION]-(t:Taxi) "
+ "WITH t, p, REDUCE(totalTime = 0, x IN RELATIONSHIPS(p) | totalTime + x.time) AS totalTime "
+ "WHERE totalTime <= 6 RETURN t.name as Taxi LIMIT 3";
Result taxiNeighbor = graphDb.execute(query2);
两个查询都返回相同的元素(出租车),是否可以将两个执行的结果合并为一个结果,所以最后我有一个“表”显示所有结果。
WILL_GO Taxis:
+----------+
| Taxi |
+----------+
| "taxi 4" |
+----------+
NEIGHBOR Taxis:
+----------+
| Taxi |
+----------+
| "taxi 2" |
| "taxi 1" |
| "taxi 4" |
+----------+
e.g Merged Table WILL GO and NEIGHBOR
+----------+
| Taxi |
+----------+
| "taxi 2" |
| "taxi 1" |
| "taxi 4" |
+----------+
提前谢谢你!
【问题讨论】: