neo4j - match a node that has direct links to all nodes in a set -
when there 2 nodes in set , it's relatively easy
match (a:article {id : "pmid:16009338"}),(c:article {id: "pmid:21743479"}) a, c match (a)-[r]-(d)-[r1]-(c) return d
but similar attempt 3 nodes didn't work
match (a:article {id : "pmid:16009338"}),(c:article {id: "pmid:21743479"}), (p:article {id: "pmid:21741956"}) a, c, p match (a)-[r]-(d)-[r1]-(c)-[r2]-(d)-[r3]-(p) return d
it looks different relation between c , d. r1 , r2. if change r2 r1 says : cannot use same relationship variable 'r1' multiple patterns.
even if make work impossible set of 4+ nodes.
==== attempt 3 nodes different types executes fast enough
match (a:article {id : "aid:16009338"}),(v:video {id: "vid:21743479"}), (s:song {id: "sid:21741956"}) a, v, s match (a)-[]-(d) d, v, s match (v)-[]-(d) d, s match (s)-[]-(d) return d
you common node against list of articles , make sure number matched afterwards same number matching against.
with ['pmid:16009338','pmid:21743479','pmid:21741956'] articles match (d)--(a:article) a.id in articles articles, d, collect(a) matched size(articles) = size(matched) return d
Comments
Post a Comment