I am trying to write a query to return all related nodes related by "IMMEDIATE_FAMILY_MEMBER"
This is my query so far
MATCH (f:NaturalPerson)-[r:IMMEDIATE_FAMILY_MEMBER*1..6]-(t)
WHERE f.Name="Jacob"
RETURN f AS fromNode, t AS toNode, r AS Metadata
Initially i thought it worked quite well, but as soon as i added a the child Thuthukile (Parents Jacob and Nkosazana) i get "duplicate" results.
At the moment the query will return a pair of related nodes and all the relationships that were traversed to link them together (ie the metadata).
How do i change this query so i return a distinct pair of nodes with the shortest path (all the relationships) between them.
Also as an extra question, is it possible to specify an or for the label of the relation itself. Ie, the same query but also include the :KNOWS relationship
Edit:
cybersams answer was correct, i made one small change to get the result i wanted.
My final query was this
MATCH (f:NaturalPerson)-[r:IMMEDIATE_FAMILY_MEMBER*..6]-(t)
WHERE f.Name="Jacob" AND t.Name<>"Jacob"
WITH f, t, r
ORDER BY SIZE(r)
RETURN f AS fromNode, t AS toNode, COLLECT(r)[0] AS Metadata
I needed to exclude the "from person" as a destination as i was not interested in the shortest path back to the parent