Hello People,
I need help in optimizing my Neo4j Queries based on some scenarios:
-
If( the rating of the Distributor is lessened because of quality issues)
(If there is another Distributor that supplies the same item is available) Then(Order from the new Distributor with a good rating)
MATCH n=(d:Distributor)-[de:Delivers]->(r:Retailer)-[s:Sells]->(p:Product) WHERE d.name = "Costco" and p.name = "a"
SET d.Rating = 3.5
WITH d,r,p
MATCH (d)-[de: Delivers]->(r)-[s: Sells]->(p)
WHERE p.name = "a"
AND d.rating > 3.5
WITH collect(d) as goodDistributors
UNWIND goodDistributors as distributorList
OPTIONAL MATCH (r:Retailer)-[o:Orders{Product:"a"}]->(d:Distributor{name:"Costco"})
DELETE o
FOREACH (d2 in distributorList| CREATE (r)-[o2:Orders{Product:"a"}]->( d2))
Any help will be appreciated.