How to load all related node without includeing them in cypher in noe4jclinet

64 views Asked by At

I am building a Query for cypher using Neo4jClient base on User search term. my question is how can i load all the related nodes to first node that i am searching for.

here is a code sample in neo4jclient :

q.Return(post => post.As<Post>()).OrderBy("post.creationDate");

which produce something like this in cypher but without the result part:

MATCH (post:Post)-[:HAS_MentionedUsers]->(assignee1307989068:User),(post:Post)-[:HAS_HashTags]->    (Hashtag1841024507:HashTag)
WHERE (assignee1307989068.UserName = "mhs")
OR (Hashtag1841024507.Value = "myTag")

I am searching for the post but i need all the related node to Post to be included in the result set.

1

There are 1 answers

2
Michael Hunger On

Make sure to have indexes for :User(UserName) and :HashTag(Value)

You create a cross product here, not sure that you want this, probably a union is better

You can just expand the pattern to contain other relationships off :Post too.

MATCH (o)-[r]-(post:Post)-[:HAS_MentionedUsers]->(assignee1307989068:User),
WHERE (assignee1307989068.UserName = "mhs")
RETURN post,o,r
UNION
MATCH (o)-[r]-(post:Post)-[:HAS_HashTags]->    (Hashtag1841024507:HashTag)
WHERE (Hashtag1841024507.Value = "myTag")
RETURN post,o,r