Reputation: 285
I have two relationships in my cypher query: CREATE_BY and LIKE
I want to list down all blogs created by someone, people can LIKE blog, so i also want to know the likesCount too, below query has one problem is that when nobody LIKE this blog, then this blog won't be in the results. How to fix it? Thanks in advance.
@Query("START owner=node({0}) MATCH owner<-[:CREATE_BY]-blog WHERE blog.status = 0
WITH blog MATCH blog<-[:LIKE]-user RETURN blog, count(*) AS likesCount ORDER BY
blog.createDate DESC")
Upvotes: 1
Views: 552
Reputation: 314
For starters, try making the LIKE relationship optional, e.g blog<-[?:LIKE]-user. Here's doc link for neo4j 1.9.5
http://docs.neo4j.org/chunked/1.9.5/query-match.html#match-optional-typed-and-named-relationship
Upvotes: 2