Neo4j:结果重复

Neo4j: results are duplicated

所以我试图找到至少与另一个节点有共同节点的每个节点。这是我用来执行此操作的请求:

MATCH (source:Article)--(neighbor)--(target:Article)
WHERE NOT (source.unique_url) = (target.unique_url)
WITH DISTINCT [source.unique_url, target.unique_url] AS combo, 
     source, target, neighbor 
RETURN combo, 
       source.unique_url AS source_unique_url, 
       source.title AS source_title, 
       source.url AS source_url, 
       target.unique_url AS target_unique_url, target._id AS target_id,
       target.title AS target_title,  
       count(neighbor) AS common_neighbors
ORDER BY common_neighbors DESCENDING

但遗憾的是 [source.unique_url, target.unique_url] 总是重复的,比如一个节点与另一个节点有共同的邻居,我总是得到这样的结果:

[url1, url2]
[url2, url1]
[url1, url2]
[url2, url1]

我检查了一下,数据库中的数据没有重复,所以请求是重复的,有人知道是什么原因造成的吗? 非常感谢!

尝试像这样更改查询的开头。

  1. 为关系添加方向
  2. 添加 id(来源) > id(目标)
MATCH (source:Article)-->(neighbor<)--(target:Article)
WHERE id(source) > id(target)
WITH ...