-
Notifications
You must be signed in to change notification settings - Fork 44
Description
Hi,
I would like to have your opinion on the way of adding MATCH clauses. At the moment, when we chain ->match() methods you add a comma, to separate the patterns.
It seems that this way of chaining MATCH patterns (with a comma) works well with basic patterns like (node1)-[:directRelation]->(node2). But in my case, I would like to match nodes (with specific labels) which are not directly connected to other nodes (with a different label).
I'm facing a problem with this kind of request:
match (list:List)-[:contains]->(product:Product)
where (ID(list) IN [740])
match (product:Product)-[*]->(product_sector:ProductSector),(product:Product)-[*]->(product_family:ProductFamily),(rating:Rating)-[:object]->(product:Product),(rating:Rating)-[:hasType]->(group:RatingGroup)
where (ID(group) IN [730])
return product.name AS name,product_sector.name AS product_sector,product_family.name AS product_family,group.name AS type, rating.numericalValue AS value
I would like to fetch all products contained in a specific list and I want to match other node information related to each Product like ProductSector, ProductSector but I only want Products which have a Rating and where the ratings belong to a specific RatingGroup.
With this syntax I have "no rows" as result.
I found out (thanks to the nice answers on this topic)
that the use of a comma in a MATCH clause means that we are looking for multiple connected patterns. Example :
MATCH (a)-->(b)<--(c), (b)-->(d) is the equivalent of MATCH (a)-->(b)<--(c)-->(d)
But in my case, I'm looking for unconnected patterns. As inside each MATCH clause, each relationship will be traversed only once, I edited the Cypher.php in order to add automatically a MATCH clause by default.
Moreover I don't use the func_get_args because we lose the ability of supplying default values.