Neo4j 2.0:SKIP,LIMIT,ORDER UNION返回的所有结果?

时间:2013-10-22 13:00:07

标签: neo4j

我有三个与UNION子句结合的查询:

CYPHER 2.0
START user=node:User(Id="2")
MATCH (user)-[:FOLLOWS_USER]->()-[:SHARES]->(post)-[?:ORIGINAL]->(original)
WHERE original is null
RETURN distinct post.Id AS Id, post.CreationTime AS CreationTime
UNION
MATCH (user)-[:FOLLOWS_USER]->()-[:LIKES]->(post)
WITH post, count(post) as likes
WHERE likes >= 0
RETURN distinct post.Id AS Id, post.CreationTime AS CreationTime
UNION
MATCH (user)-[:FOLLOWS_USER]->()-[:SHARES]->(post)-[repost:ORIGINAL]->()
WITH post, count(repost) as reposts
WHERE reposts >= 0
RETURN distinct post.Id AS Id, post.CreationTime AS CreationTime
ORDER BY post.CreationTime desc
SKIP 0
LIMIT 100;

我希望将SKIPLIMITORDER BY应用于整个结果集,而不是单个查询。我相信这也是它在SQL中的工作方式。但是,我认为Neo4j不是这种情况,因为我可以从desc中删除ORDER BY并且订单保持不变。

这是预期的行为吗?有没有办法可以编写查询,以便我可以将SKIPLIMITORDER BY应用于整个结果集?

我也不确定是否必须在每个子查询中重复行START user=node:User(Id="2"),因为2.0中的查询可以在没有START子句的情况下启动。我必须重复一遍吗?

关于UNION关键字,恕我直言,Neo4j文档有点模糊。

1 个答案:

答案 0 :(得分:1)

目前尚不支持,因为在此之前需要支持子查询才能正确实现。