简体   繁体   中英

Fixing inconsistent Cypher results in Neo4j

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?

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?

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.

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