简体   繁体   中英

Neo4j query relationship property

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

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.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM