Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
08-06-2020 09:21 AM
MATCH (p)-[:HAS_CATEGORY]->(c:ProductCategory)
WHERE p.accountGUID = 'xxxxxxxxxx' AND NOT c.id IN ['76','1330', '65','1402', '1152','64','59']
return p
Products are being returned from the above query that DO have relationships with categories from the collection that should be filtered out. Am I misunderstanding how the WHERE NOT IN clause works with respect to relations?
Any help or explanation is appreciated! Thank you!
08-06-2020 10:13 AM
Could it be that p is associated with other categories that are not in the list. In that case this would return that p even though it might be associated with the categories provided in the list as there is a path.
Ex: Say this is the data
(p)-[:HAS_CATEGORY]->(c:ProductCategory {id:'76')
(p)-[:HAS_CATEGORY]->(c:ProductCategory (id:'75')
In this case there is MATCH for category id 75 that is returned. So, you will get that p node returned.
If you don't want any p returned if that is associated with the specified categories irrespective of other connections then query should be like this
MATCH (p)-[:HAS_CATEGORY]->(c:ProductCategory)
WHERE p.accountGUID = '1234'
WITH p, collect(c.id) as categories
WHERE none( x in categories WHERE x in ['76','1330', '65','1402', '1152','64','59'] )
return p
All the sessions of the conference are now available online