Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
neo4j如何在路径的节点上使用count(distinct())_Neo4j_Cypher - Fatal编程技术网

neo4j如何在路径的节点上使用count(distinct())

neo4j如何在路径的节点上使用count(distinct()),neo4j,cypher,Neo4j,Cypher,我搜索我的图的最长路径,我想计算这个最长路径的不同节点的数量 我想使用count(distinct()) 我试过两个问题 首先是 match p=(primero)-[:ResponseTo*]-(segundo) with max(length(p)) as lengthPath match p1=(primero)-[:ResponseTo*]-(segundo) where length(p1) = lengthPath return nodes(p1) 查询结果是一个带有路径节点的图

我搜索我的图的最长路径,我想计算这个最长路径的不同节点的数量

我想使用
count(distinct())

我试过两个问题

首先是

match p=(primero)-[:ResponseTo*]-(segundo)
with max(length(p)) as lengthPath
match p1=(primero)-[:ResponseTo*]-(segundo)
where length(p1) = lengthPath
return nodes(p1)
查询结果是一个带有路径节点的图

但是如果我试着问

match p=(primero)-[:ResponseTo*]-(segundo)
with max(length(p)) as lengthPath
match p1=(primero)-[:ResponseTo*]-(segundo)
where length(p1) = lengthPath
return count(distinct(primero))
结果是

count(distinct(primero))
2
如何在节点primero上使用
count(distinct())


节点PrimeRo有一个字段称为ID.< /P> < P>你应该至少绑定其中一个节点,添加一个方向,也考虑一个路径限制,否则这是一个非常昂贵的查询。

match p=(primero)-[:ResponseTo*..30]-(segundo)
with p order by length(p) desc limit 1
unwind nodes(p) as n
return distinct n;