Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
09-26-2018 10:09 PM
Hello People,
I need help in optimizing my Neo4j Queries based on some scenarios:
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.
09-28-2018 09:35 AM
Hi,
To find all the distributors for the product p="a" with rating greater than 3.5, try this query:
MATCH (d:Distributor)-[de:Delivers]->(r:Retailer)-[s:Sells]->(p:Product)
WHERE p.name = "a" and d.name <> "Costco"
AND d.rating > 3.5
Use this list to perform other activities.
-Kamal
All the sessions of the conference are now available online