Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
02-25-2021 03:42 AM
Hi all, I am storing graphs in the catalogue and have an issue when using variable-length matching and it's sophisticated older sister apoc.path.expand...
The dataset is all UK companies and company officers and is very fragmented. There is a wide variety of clusters sizes. I want to be able to expand x hops.
In testing, if I write the relationshipsQuery path long-hand:
(o1:Officer)-[:IS_OFFICER]-(c:Company)-[:IS_OFFICER]-(o2:Officer)
I get the expected results
But if I try either variable-length matching (or apoc.path.expand.. but not shown in this example), using this relationshipQuery - which should be equivalent to the long-hand version (I think?)
MATCH p = (o1:Officer)-[:IS_OFFICER*..2]-(c:Company) WHERE o1.postcode STARTS WITH "BS6 6" UNWIND relationships(p) as rel WITH startNode(rel) as start, endNode(rel) as end RETURN id(start) AS source, id(end) AS target
The node count is the same but no relationships are stored??
Any help feedback very much appreciated,
Cheers,
Mike
Solved! Go to Solution.
03-04-2021 06:27 AM
I think the label for c
should be Officer
rather than Company
?
MATCH p = (o1:Officer)-[:IS_OFFICER*..2]-(c:Officer)
WHERE o1.postcode STARTS WITH "BS6 6"
UNWIND relationships(p) as rel
WITH startNode(rel) as start, endNode(rel) as end
RETURN id(start) AS source, id(end) AS target
03-04-2021 06:27 AM
I think the label for c
should be Officer
rather than Company
?
MATCH p = (o1:Officer)-[:IS_OFFICER*..2]-(c:Officer)
WHERE o1.postcode STARTS WITH "BS6 6"
UNWIND relationships(p) as rel
WITH startNode(rel) as start, endNode(rel) as end
RETURN id(start) AS source, id(end) AS target
03-04-2021 10:30 AM
Of course!! Thanks Mark
All the sessions of the conference are now available online