有没有办法像在 SQL 中那样在 Neo4j 中的 FROM 中制作类似于 SELECT 的东西?

问题描述 投票:0回答:0

我必须做一个查询,得到转发最讨人喜欢的人的帖子的列表。

它必须是一个查询,但我只能通过两个查询来完成。 我试过

OPTIONAL MATCH
CALL
子句,但它仍然不起作用,我不明白我到底做错了什么。

这是我的两个问题:

1)

match (per1:Person)-[r1:LIKE]->(p:Post)<-[:CREATE]-(per2:Person)
return per2.name, count(r1) order by count(r1) desc limit 1

(我发现帖子点赞最多的作者是Emily Douson,所以下一步:)

2)

match (per:Person)-[:REPOST]->(p:Post)<-[:CREATE]-(per2: Person {name:"Emily Douson"})
return distinct per.name

问题是通过

OPTIONAL MATCH
我可以获得作者列表,但不是我需要使用的一位作者。

我尝试使用

CALL
看起来像:

call {
  match(per1:Person)-[r1:LIKE]->(p:Post)<-[:CREATE]-(per2:Person)
  return per2.FIO as personX, count(r1) as countL order by countL desc limit 1
}
with personX
match (per:Person)-[:REPOST]->(p:Post)<-[:CREATE]-(personX)
return distinct per.FIO

但我收到消息:

Type mismatch: personX defined with conflicting type Boolean, Float, Integer, Number, Point, String, Duration, Date, Time, LocalTime, LocalDateTime, DateTime, List<Boolean>, List<Float>, List<Integer>, List<Number>, List<Point>, List<String>, List<Duration>, List<Date>, List<Time>, List<LocalTime>, List<LocalDateTime> or List<DateTime> (expected Node) (line 2, column 51 (offset: 212))
"match(per:Person)-[:REPOST]->(p:Post)<-[:CREATE]-(personX) return distinct per.FIO"
neo4j cypher
© www.soinside.com 2019 - 2024. All rights reserved.