【问题标题】:cypher merge executed results java密码合并执行结果java
【发布时间】: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" |
    +----------+

提前谢谢你!

【问题讨论】:

    标签: java merge cypher


    【解决方案1】:

    您可以使用UNION Cypher 子句组合两个查询的结果:http://neo4j.com/docs/stable/query-union.html

    MATCH ...
    RETURN t
    
    UNION
    
    MATCH ...
    RETURN t
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-02
      相关资源
      最近更新 更多