I'm trying to write a Cypher query for this social network type of application that I'm working on. Just think of a Facebook type of application where you have users who follow other users and the users can write posts and like/share them.
Let's say user Alice follows a couple of people (the subjects).
What the query should return is three things:
I'm able to write the three queries separately:
start alice=node(35500)
match (alice)-[:FOLLOWS]->()-[:SHARES]->(post)
where not((post)-[:ORIGINAL]->())
return post;
start alice=node(35500)
match (alice)-[:FOLLOWS]->()-[:LIKES]->(post)
with post, count(post) as likes
where likes >= 5
return post;
start alice=node(35500)
match (alice)-[:FOLLOWS]->()-[:SHARES]->(post)-[repost:ORIGINAL]->()
with post, count(repost) as reposts
where reposts >= 5
return post;
(a repost has an :ORIGINAL relationship to its original post)
At the moment I'm doing the three queries separately, combining, sorting and paging the results in the client. What I really want is a single query, where I can page the results with SKIP and LIMIT.
As far as I can tell, UNION is not supported in Neo4j 1.9, which is the (stable) version I'm using. Upgrading to an unstable Neo4j 2.0 is not really an option.
Is there a way to do this without Neo4j's UNION?
Thanks!
我认为在Neo4j 1.9中,在这种情况下,您应该移至服务器插件或Java代码,Cypher在2.0之前并不真正支持此功能。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.