Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
10-09-2019 04:59 AM
Hi everyone,
is it possible to follow a relationship vector in Neo4j? The key word here is the start of the vector.
For example , I have the following dataset: (:node {name:A})-[:supplies]->(:node {name:B)-[:supplies]->(:node{name:C})-[:supplies]->(:node{name:D})
I would like to be able to define beginning for my query. For example - get all nodes which node C supplies. Currently my query returns all nodes - A,B,C and D, even though I start from node C. So is there a vectoring query, where I am able to set a start in the dataset and follow a direction? In other word to receive node D only?
And I don't mean to use the WHERE clause manually for this particular example. In my app the nodes chain might be hundreds, being input via a webapp, and each node might have different owner. So I need a function in which I can set a starting node and follow direction in the relation
10-10-2019 06:48 PM
Hey, post your actual code, outline your use case in regards to a detailed model.
10-16-2019 03:21 PM
Yes, you just need to use a variable-length relationship pattern, and ensure you include the direction of the relationships as well as make sure your starting node is defined.
An index or unique constraint to support the lookup of your starting node is also important, so ensuring something like CREATE INDEX ON :node(name)
will help.
MATCH (:node {name:'C'})-[:supplies*]->(n:node)
RETURN n.name as nodeSuppliedByC
All the sessions of the conference are now available online