在Qlikview中匹配命令

时间:2014-07-24 05:20:35

标签: neo4j

我使用create语句在Neo4j中只创建了一个图形。现在我想使用MATCH命令从同一图表中检索数据。它给了我所有节点和关系的正确计数。现在我再次运行相同的创建查询而没有任何更改,现在如果我使用相同的MATCH检索计数,那么我得到双值。如果再次运行它然后三倍值。如果我在create语句中给出return语句,那么计数是正确的,如果我单独给它,那么计数就会成倍增加。

为什么会这样。

如果我多次运行相同的图表,如何获得正确的计数。

LOAD CSV FROM "file:D:\\Neo4j\\demo2dbcopy.csv" AS emp
MERGE (root:SubGraph {source: emp[7]})
MERGE (cname:Cmpname {name: emp[0]}) 
MERGE (clusters:ClustName { name: emp [1]}) 
MERGE (dom:domains { name: emp [2]}) 
MERGE (Hd:Head { name: emp [3]}) 
MERGE (DelHd:DeliveryHead { name: emp [4]}) 
MERGE (Mgr:Managers { name: emp [5]}) 
MERGE (Emp:Employees { name: emp [6]}) 
CREATE (root)<-[:PART_OF_SUB_GRAPH]-(cname)-[:has]->(clusters),(clusters)-[:contains]->(dom)<-[:headedby]-(Hd),
      (Hd)-[:equals]->(DelHd),
      (DelHd)-[:assistedby]->(Mgr),
      (Mgr)-[:Dividesinto]->(Emp) 
return root,cname,clusters,dom,Hd,count(Hd);

和MATCH语句是

MATCH (root:SubGraph {source: "demo2db"})<--(cname:Cmpname)-->(clusters:ClustName)-->(dom:domains {name:"BIDW"})<-[:headedby]-(Hd:Head) RETURN dom.name, count (Hd);

提前致谢...

1 个答案:

答案 0 :(得分:0)

create命令是

 LOAD CSV FROM "file:D:\\Neo4j\\demo2dbcopy.csv" AS emp
    MERGE (root:SubGraph {source: emp[7]})
    MERGE (cname:Cmpname {name: emp[0]}) 
    MERGE (clusters:ClustName { name: emp [1]}) 
    MERGE (dom:domains { name: emp [2]}) 
    MERGE (Hd:Head { name: emp [3]}) 
    MERGE (DelHd:DeliveryHead { name: emp [4]}) 
    MERGE (Mgr:Managers { name: emp [5]}) 
    MERGE (Emp:Employees { name: emp [6]}) 
    CREATE (root)<-[:PART_OF_SUB_GRAPH]-(cname)-[:has]->(clusters),(clusters)-[:contains]->(dom)<-[:headedby]-(Hd),
   (Hd)-[:equals]->(DelHd),
          (DelHd)-[:assistedby]->(Mgr),
          (Mgr)-[:Dividesinto]->(Emp) 
    return root,cname,clusters,dom,Hd,count(Hd);

和MATCH语句是

MATCH(root:SubGraph {source:&#34; demo2db&#34;})&lt; - (cname:Cmpname) - &gt;(clusters:ClustName) - &gt;(dom:domains {name: &#34; BIDW&#34;})&lt; - [:headsby] - (Hd:Head)返回计数(Hd);