Neo4j collection function error? -
i running following query meant compare 2 collections nodes set1 , set2. nodes in set2 in set1, , identify nodes in set1 not in set2. however, query returns set of nodes includes of nodes in set1. running query on v2.1.7. suggestions?
query:
match p=(a:objectconcept{sctid:233604007})<-[:isa*]-(b:objectconcept) nodes(p) set1, p match q=(a:objectconcept{sctid:34020007})<-[:isa*]-(b:objectconcept) nodes(q) set2,set1, p all(x in set2 not x in set1) nodes(p) pneumo unwind pneumo pneumolist return distinct pneumolist.fsn,pneumolist.sctid
alternative query, same result: query:
match p=(a:objectconcept{sctid:233604007})<-[:isa*]-(b:objectconcept) nodes(p) set1, p match q=(a:objectconcept{sctid:34020007})<-[:isa*]-(b:objectconcept) nodes(q) set2,set1, p none(x in set2 x in set1) nodes(p) pneumo unwind pneumo pneumolist return distinct pneumolist.fsn,pneumolist.sctid
your matches don't return 1 row might expect many rows, , comparison done between cross product of many row combinations. want create set each of 2 subtrees first combination of unwind + collect(distinct)
the code below not fast, cypher internally doesn't have set
concept yet.
try this
match p=(a:objectconcept{sctid:233604007})<-[:isa*]-(b:objectconcept) unwind nodes(p) n collect(distinct n) set1 match q=(a:objectconcept{sctid:34020007})<-[:isa*]-(b:objectconcept) unwind nodes(q) m collect(distinct m) set2 none(x in set2 x in set1) unwind set1 pneumolist return distinct pneumolist.fsn,pneumolist.sctid