On Thu, Dec 8, 2011 at 12:49 AM, Michael Hunger < michael.hun...@neotechnology.com> wrote:
> start shop=node(123), me=node(321) > match shop-[:sell]->item<-[:like]-user,item<-[r1?:like]-me > where r1 is null > return item > > the missing part was the optional relationship for r1, which allows it to > be null and you check for those results, where no relationship between me > and item exists. > In SNAPSHOT, we now support relationship predicates<http://docs.neo4j.org/chunked/snapshot/query-where.html#where-filter-on-relationships>in the WHERE clause. That means that you don't have to do this optional relationship trick. You can write: start shop=node(123), me=node(321) match shop-[:sell]->item<-[:like]-user where not(item<-[:like]-me) return item If what you are looking for is all items for this shop that someone has liked, you probably want to this: RETURN DISTINCT item Otherwise, you'll get the items once per user that has liked it. As a note: what we probably really should do is allow this query instead: (This is not supported today!) start shop=node(123), me=node(321) match shop-[:sell]->item where item<-[:like]-() return item In the first query, we do a big pattern match, and then trim away a lot of the results. This second query allows Cypher to be clever and do much less work. Andrés _______________________________________________ NOTICE: THIS MAILING LIST IS BEING SWITCHED TO GOOGLE GROUPS, please register and consider posting at https://groups.google.com/forum/#!forum/neo4j Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user