Reputation: 634
Neo4j newbie here. I have a graph database with node as Person, edges between nodes are relationship POSTED, POSTED has property "message", now I would like to return relationship with certain message. I wrote query like:
MATCH (ppl) -[p:POSTED]->(s)
WHERE p.message = "How are you?"
RETURN p
It returns nothing.
What is the right way to make relationship queries? Can I make some queries like:
MATCH (a) -[:KNOWS]->(ppl),
(ppl) -[p:POSTED]->(s)
WHERE p.message = "How are you?"
RETURN p
Upvotes: 0
Views: 76
Reputation: 8731
Creating a lot of same Relations between two nodes is not a good idea if you want to create something like a chat.
In fact, it'll be a lot more easier and faster to create a model like this:
(:User{Foo:"Bar})-[:POSTED]->(:Message{content:"Hello World"})-[:SENT_TO]->(:User{Foo:"blabla"})
This way, you'll be able to store way more thing in your messages and It's easier to do operations with nodes.
You can check this reddit topic to find out the best practices to do what you want.
Upvotes: 1