2
votes

I've been getting some strange results with a Neo4j database I made (version 2.1.0-M01). I have a graph with the following relationship:

Node[211854]{name : "dst"} <-[:hasrel]- Node[211823]{name : "src"}

I've confirmed this relationship using the following query:

START m=node(211854) MATCH (m)<-[r]-(n) RETURN m,r,n;

which returns a one row result, as expected:

| m             | r                 | n
| Node[211854]  | :hasrel[225081]   | Node[211823]

The following query returns nothing, however:

START n=node(211823) MATCH (m)<-[r]-(n) RETURN m,r,n

Any thoughts on what might be happening? I've run these queries with and without indexes on the name properties for the nodes.

EDIT: Fixed typo with initial node number. EDIT2: I rebuilt the server and both queries return the results I expect. Perhaps the error was corruption in the first database?

2
Nice first question! Thanks for reading the help files first.Tom Zych
Not sure if this has anything to do with your problem, but there is a discrepancy (typo?) in your question: first line of code has node with id 211845, rest of your question has 211854.jjaderberg
WE noticed the exact same issue in one of our Neo4J db's in a clustered environment where each nodes was reporting inconsistent results across the cluster and also the same discrepancy as above on a given node. Restarting the Neo4J servers magically fixed this, but leaves us very concerned about how reliable Neo4J is in the face of ongoing updates to the db. I thought it was supposed to be transactional.user2456600

2 Answers

0
votes

Using the node id's is not such a good idea, you can use the properties on your node to query them.

For example:

MATCH (m)<-[r]-(n {name: "src"}) RETURN m,r,n;

Does that query return what you expected?

0
votes

You have to invert the relationship-direction. As you are looking for incoming relationships for your node 211823, this is not one of them. It's an outgoing relationship.

Please also update your database to the current version: 2.1.2 http://neo4j.org/download

START n=node(211823) MATCH (m)-[r]->(n) RETURN m,r,n

Perhaps you should give your nodes and relationships more descriptive names, so you spot easier when you inverted a domain concept.