gpt4 book ai didi

neo4j - 按关系计数对节点进行排序 --> ThisShouldNotHappenError

转载 作者:行者123 更新时间:2023-12-04 02:50:23 26 4
gpt4 key购买 nike

在具有几个节点和关系的 Neo4j 数据库中,我试图找出最“流行”的用户(在这种情况下:参与大多数关系的节点):

START n=node:user('*:*')
MATCH (n)-[r]->(x)
RETURN n
ORDER BY COUNT(r) DESC
LIMIT 10

但是,此查询 (Neo4j 1.9.2) 导致以下错误:

ThisShouldNotHappenError

Developer: Andres claims that: Aggregations should not be used like this.

StackTrace: org.neo4j.cypher.internal.commands.expressions.AggregationExpression.apply(AggregationExpression.scala:31) org.neo4j.cypher.internal.commands.expressions.AggregationExpression.apply(AggregationExpression.scala:29) org.neo4j.cypher.internal.pipes.ExtractPipe$$anonfun$internalCreateResults$1$$anonfun$apply$1.apply(ExtractPipe.scala:47) org.neo4j.cypher.internal.pipes.ExtractPipe$$anonfun$internalCreateResults$1$$anonfun$apply$1.apply(ExtractPipe.scala:45) scala.collection.immutable.Map$Map1.foreach(Map.scala:109) org.neo4j.cypher.internal.pipes.ExtractPipe$$anonfun$internalCreateResults$1.apply(ExtractPipe.scala:45) org.neo4j.cypher.internal.pipes.ExtractPipe$$anonfun$internalCreateResults$1.apply(ExtractPipe.scala:44) scala.collection.Iterator$$anon$11.next(Iterator.scala:328) org.neo4j.cypher.internal.pipes.TopPipe.internalCreateResults(TopPipe.scala:45) org.neo4j.cypher.internal.pipes.PipeWithSource.createResults(Pipe.scala:69) org.neo4j.cypher.internal.pipes.PipeWithSource.createResults(Pipe.scala:66) org.neo4j.cypher.internal.executionplan.ExecutionPlanImpl.org$neo4j$cypher$internal$executionplan$ExecutionPlanImpl$$prepareStateAndResult(ExecutionPlanImpl.scala:164) org.neo4j.cypher.internal.executionplan.ExecutionPlanImpl$$anonfun$getLazyReadonlyQuery$1.apply(ExecutionPlanImpl.scala:139) org.neo4j.cypher.internal.executionplan.ExecutionPlanImpl$$anonfun$getLazyReadonlyQuery$1.apply(ExecutionPlanImpl.scala:138) org.neo4j.cypher.internal.executionplan.ExecutionPlanImpl.execute(ExecutionPlanImpl.scala:38) org.neo4j.cypher.ExecutionEngine.execute(ExecutionEngine.scala:72) org.neo4j.cypher.ExecutionEngine.execute(ExecutionEngine.scala:76) org.neo4j.cypher.javacompat.ExecutionEngine.execute(ExecutionEngine.java:79) org.neo4j.server.rest.web.CypherService.cypher(CypherService.java:94) java.lang.reflect.Method.invoke(Method.java:611) org.neo4j.server.rest.security.SecurityFilter.doFilter(SecurityFilter.java:112)



关于如何以不同方式表达这一点的任何想法?

最佳答案

在neo4j手册方面,如果您需要在“Order by”中使用聚合,则必须在“Return”中包含该聚合,因此您只需在“Return”中添加count(r),如下所示,

START n=node:user('*:*')
MATCH (n)-[r]->(x)
RETURN n, COUNT(r)
ORDER BY COUNT(r) DESC
LIMIT 10

关于neo4j - 按关系计数对节点进行排序 --> ThisShouldNotHappenError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18329904/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com