0
votes

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
1
What do you get if try the following query: MATCH (ppl) -[p:POSTED]->(s) RETURN p LIMIT 10 - Olivier De Meulder
I will reture all the nods with POSTED relationship to others. Here is how edge added: (Nick)-[:POSTED {messsage: 'How are you?'}]->(Sam) - Daolin
Are the three sss in messsage a typo? - Olivier De Meulder
It was provided by someone else. That is why it not working. Thank you. I'm so embarrassed. How do I close this question? - Daolin

1 Answers

1
votes

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.