0

I have two nodes, A and B, A talks to B and B talks to A, (A)-[:talksTo]-(B)

A has a sentiment value towards B, and B has a sentiment value towards A.

So there is the problem, I need A to B relationship to store a value that the B to A relationship will also want to store (same key).

So I will try to do queries such as, MATCH (A:person)-[:talksTo]-(B:person) where A.sentiment < -2 return A;

So here A's sentiment toward B will be different the B's sentiment toward A, thus the needed separation.

I have tried to make unique key names to specify direction - but that makes queries difficult unless I can query with a wild card ex: ... where A.Asentiment < -2 would be queried as ... where A.*sentiment < -2

Another way I can think of to do this is make two different graphs, 1) A talks to B graph and B talks to A graph... but this would make queries tricky as I may get back more then one node for single node queries OR if I have to update a single node key:value to something else. I would prefer to have one node name per person.

Any ideas?

  • I'm a bit confused. Is the sentiment value on the node or the relationship? When you say `A.sentiment` that implies that it's on the node. – Brian Underwood Dec 26 '14 at 08:52
  • you are correct I used mis-leading notation. A.Sentiment here refers to the sentiment on the relations towards B. So it should have been (A)->[R:talksTo {sentiment:'10'}]->(B), where the sentiment variable is the issue. there cant be more then one edge between any two nodes and A wants to talk to B with some variables that are the same as B wants to talk to A with. I have currently gotten around this by creating multiple nodes, by saying (Aout)-[:talksTo]->(Bin), (Bout)-[:talksTo]->(Ain); but I wonder if there was a better solution –  Dec 27 '14 at 19:16
  • You should definitely be able to have two relationships, each one going the opposite direction of the other, but still between the same two nodes. Have you tried it? Does it give you an error? – Brian Underwood Dec 28 '14 at 09:33
  • Have a look at this post which might shed some light on bi-directional relationships in Neo4j: http://graphaware.com/neo4j/2013/10/11/neo4j-bidirectional-relationships.html – Michal Bachman Dec 28 '14 at 16:20
  • yeah I tired it, it replaces the old relationship with the new one. I am thinking it is just not possible, and that making multiple nodes is the only way to go (not to make queries so messy). In fact the first comment posted (at the bottom of the page) on the link provided by @Michal. Talks about this issue –  Dec 28 '14 at 22:29

1 Answers1

0

I don't know that this is a solution, but I don't think I understand enough so it might be a foil for better understanding:

MATCH (A:Person)-[dir1:talksTo]->(B:Person), (A)<-[dir2:talksTo]-(B)
WHERE dir1.sentiment < 2
RETURN A, B
Brian Underwood
  • 10,746
  • 1
  • 22
  • 34