Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
05-20-2020 03:27 AM
I think this is a newbie question but cannot sort it out.
Me unfinished query looks like this:
MATCH (manufacturer:Manufacturer)-[:HAS_BRAND]->(brand:Brand)
// Here I need something to filter manufacturers where ALL Brand nodes have the label Ready.
// If at least one 'Brand' node is not 'Ready' then don't return those manufacturers.
RETURN DISTINCT manufacturer
Thanks
Solved! Go to Solution.
05-20-2020 02:23 PM
We can do this with pattern comprehensions (which let us get the results of a MATCH in a list) and the all() list predicate:
MATCH (manufacturer:Manufacturer)
WHERE all(brand in [(manufacturer)-[:HAS_BRAND]->(brand) | brand] WHERE brand:Ready)
RETURN manufacturer
05-20-2020 02:23 PM
We can do this with pattern comprehensions (which let us get the results of a MATCH in a list) and the all() list predicate:
MATCH (manufacturer:Manufacturer)
WHERE all(brand in [(manufacturer)-[:HAS_BRAND]->(brand) | brand] WHERE brand:Ready)
RETURN manufacturer
06-13-2020 03:09 AM
Hi,
I would like to extend my question.
I want to check 2 fields together simultaneously such as
MATCH (manufacturer:Manufacturer)
WHERE all(brand in [(manufacturer)-[:HAS_BRAND]->(brand)<-[:HAS_PART]-(part2), (brand)<-[:HAS_PART]-(part1) | [part1, part2]] WHERE part1:Ready AND part2:Ready)
RETURN manufacturer
The above doesn't really work as I am getting this error
Invalid input '|': expected whitespace, comment, a relationship pattern, '.', node labels, '[', '^', '*', '/', '%', '+', '-', "=~", IN, STARTS, ENDS, CONTAINS, IS, '=', '~', "<>", "!=", '<', '>', "<=", ">=", AND, XOR, OR, ',' or ']'
Basically the issue is contructing this array when it is required to do more than 1 match
[(manufacturer)-[:HAS_BRAND]->(brand)<-[:HAS_PART]-(part2), (brand)<-[:HAS_PART]-(part1) | [part1, part2]]
Thanks!
06-13-2020 08:03 AM
I found a long workaround
MATCH (manufacturer:Manufacturer)
WITH manufacturer,
[[(manufacturer)-[:HAS_BRAND]->(brand)<-[:HAS_PART]-(part2) | part2],[(manufacturer)-[:HAS_BRAND]->(brand)<-[:HAS_PART]-(part1) | part1]] as transposedList
UNWIND range(0,size(transposedList[0])-1) as idx
WITH [transposedList[0][idx],transposedList[1][idx]] as adjustedSeries , manufacturer
WITH collect(adjustedSeries) as adjustedList, manufacturer
....
All the sessions of the conference are now available online