Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
01-17-2021 01:05 PM
I have this query where I am trying to fetch clubs that matches as many tags in an array of tags as it can in order.
So far I have something like this (ClubTags is the array of tags):
WITH c
UNWIND (CASE $ClubTags WHEN then else $ClubTags end) AS tag
MATCH (c)-[r:HAS_TAG]->(t:ClubTag {name:tag})
RETURN c
This matches and returns clubs that match atleast one tag. But I cant seem to make out how I can expand on this to further count r (count of r always returns 1 from within UNWIND). Im guessing UNWIND is not what I should be using here but I am not sure how else I can match against all tags within the array.
edit : The squares in the abouve code are just open close of array that I am using to handle empty clubtags
Solved! Go to Solution.
01-18-2021 10:57 AM
I think... (still at intermediate level Cypher)
WITH c
MATCH (c)-[r:HAS_TAG]->(t:ClubTag)
WHERE t.name IN $ClubTags // assuming $ClubTags is [] when there are no tags
RETURN c, count(r)
01-18-2021 10:57 AM
I think... (still at intermediate level Cypher)
WITH c
MATCH (c)-[r:HAS_TAG]->(t:ClubTag)
WHERE t.name IN $ClubTags // assuming $ClubTags is [] when there are no tags
RETURN c, count(r)
01-18-2021 05:44 PM
ooo I think this would work. I will try it out tomorrow but it makes a lot of sense. Thanks a lot.
All the sessions of the conference are now available online