Neo4j 在不重复匹配的情况下使用密码查找相似节点

Neo4j 在不重复匹配的情况下使用密码查找相似节点,neo4j,cypher,Neo4j,Cypher,我是新来的。我希望在不重复匹配的情况下找到类似的节点 样本数据 CREATE (r1:Repository {id:"repository1"}) CREATE (r2:Repository {id:"repository2"}) CREATE (r3:Repository {id:"repository3"}) CREATE (a1:Actor {id: "actor1"}) CREATE (a2:Actor {id: "actor2"}) CREATE (a3:Actor {id: "a

我是新来的。我希望在不重复匹配的情况下找到类似的节点

样本数据

CREATE (r1:Repository {id:"repository1"})
CREATE (r2:Repository {id:"repository2"})
CREATE (r3:Repository {id:"repository3"})
CREATE (a1:Actor {id: "actor1"}) 
CREATE (a2:Actor {id: "actor2"}) 
CREATE (a3:Actor {id: "actor3"})
CREATE (o1:Organization {id:"organization1"})
CREATE (o2:Organization {id:"organization2"})
MATCH (a:Repository {id:"repository1"}) MATCH (b:Actor {id: 'actor1'})    
CREATE (a)-[:IS_ACTOR]->(b)
MATCH (a:Repository {id:"repository1"}) MATCH (b:Actor {id: 'actor2'})    
CREATE (a)-[:IS_ACTOR]->(b)
MATCH (a:Repository {id:"repository1"}) MATCH (b:Actor {id: 'actor3'})   
CREATE (a)-[:IS_ACTOR]->(b)
MATCH (a:Repository {id:"repository1"}) MATCH (b:Organization {id:  
 'organization1'}) CREATE (a)-[:IN_ORGANIZATION]->(b)
MATCH (a:Repository {id:"repository2"}) MATCH (b:Actor {id: 'actor1'})    
CREATE (a)-[:IS_ACTOR]->(b)
MATCH (a:Repository {id:"repository2"}) MATCH (b:Actor {id: 'actor2'}) 
CREATE (a)-[:IS_ACTOR]->(b)
MATCH (a:Repository {id:"repository2"}) MATCH (b:Organization {id: 
'organization1'}) CREATE (a)-[:IN_ORGANIZATION]->(b)
MATCH (a:Repository {id:"repository3"}) MATCH (b:Actor {id: 'actor3'}) 
CREATE (a)-[:IS_ACTOR]->(b)
MATCH (a:Repository {id:"repository3"}) MATCH (b:Organization {id: 
'organization2'}) CREATE (a)-[:IN_ORGANIZATION]->(b)
密码

MATCH (a)-[r1:IS_ACTOR|IN_ORGANIZATION]->(match)<-   
[r2:IS_ACTOR|IN_ORGANIZATION]-(b) 
where not a.id = b.id  with a,b,count(match) as count, collect (match.id) as 
connections, collect (type(r1)) as rel1 
return a.id,b.id,count,connections,rel1 order by count desc
如何从结果中删除第2行和第4行

根据对一个过滤器的响应,我尝试使用过滤器,但我得到了语法错误(下面的密码)


MATCH(a)-[r1:IS_ACTOR | IN_ORGANIZATION]->(MATCH)从两侧匹配路径一次,可以强制只返回其中一条路径。比较id,这样你就可以把a和b按固定顺序排列,避免另一个组合

MATCH (a)-[r1:IS_ACTOR|IN_ORGANIZATION]->(match)
      <-[r2:IS_ACTOR|IN_ORGANIZATION]-(b) 
where id(a) > id(b)
with a,b,count(match) as count, 
     collect (match.id) as connections, collect (type(r1)) as rel1 
return a.id,b.id,count,connections,rel1 order by count desc
MATCH(a)-[r1:IS|ACTOR|IN|u ORGANIZATION]->(MATCH)
身份证(b)
以a、b、计数(匹配)作为计数,
collect(match.id)作为连接,collect(type(r1))作为rel1
按计数说明返回a.id、b.id、计数、连接、rel1订单
MATCH (a)-[r1:IS_ACTOR|IN_ORGANIZATION]->(match)<-  
[r2:IS_ACTOR|IN_ORGANIZATION]-(b) 
with filter(x in connections where x <> b.id) 
where not a.id = b.id  with a,b,count(match) as count, collect (match.id) as   
connections, collect (type(r1)) as rel1 
return a.id,b.id,count,connections,rel1 order by count desc
MATCH (a)-[r1:IS_ACTOR|IN_ORGANIZATION]->(match)
      <-[r2:IS_ACTOR|IN_ORGANIZATION]-(b) 
where id(a) > id(b)
with a,b,count(match) as count, 
     collect (match.id) as connections, collect (type(r1)) as rel1 
return a.id,b.id,count,connections,rel1 order by count desc