
Direction can be specified in Cypher via the use of ‘<' and '> as part of a relationship pattern. Here’s an example:
1
| (jack)-[:KNOWS]->(jill) |
1
| (jack)<-[:KNOWS]-(jill) |
Relationship Direction for Writes and Reads
When a relationship is being made in Neo4j 2.3.x utilizing the Cypher query language, it requires that the direction of the relationship to be specified. This means that whenever you’re creating data within a graph via a MERGE or CREATE statement, you must always specify a direction for such relationship because Neo4j always stores a relationship with a direction. It is also beneficial because it ensures a clean and consistent data layout in the graph for your read queries.
Querying data in the graph may seem flexible in that Cypher doesn’t require specifying a direction, but it should only be done through careful consideration to the density of OUTGOING and INCOMING relationships. The important part here is that when you’re not specifying a direction for the relationship you’re matching with the
No comments:
Post a Comment