Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
03-01-2019 11:55 AM
Reading a "Learning Neo4j" book from Packt publications. Found a query:
match (p:Person)-[b:BOUGHT]->(prod1:Product)-[:MADE_BY]->(br:Brand)<-
[MADE_BY]-(prod2:Product)
with p, br, prod2, count(prod1) as NrOfBrandProducts
where not(p-[:BOUGHT]->prod2) and NrOfBrandProducts > 1
return p.name as Person, br.name as Brand, collect(prod2.name) as
RecommendedProducts
order by Person ASC;
Question: What is the best way to create a [:RECOMMED] relationship from Brand to all products in the collect(prod2)? The query is good but I need the result as a graph not records.
Is FOREACH an option?
03-01-2019 12:01 PM
but the brand is already connected to all those products? b/c it made them.
Do you mean the user? Here is one for the user.
match (p:Person)-[b:BOUGHT]->(prod1:Product)-[:MADE_BY]->
(br:Brand)<-[:MADE_BY]-(prod2:Product)
with p, br, prod2, count(prod1) as NrOfBrandProducts
where not (p)-[:BOUGHT]->(prod2) and NrOfBrandProducts > 1
merge (prod1)-[:RECOMMENDED_TO]->(p)
03-01-2019 12:09 PM
Ah, yes. I mean person. This is very helpful Michael. Thank you so much!
All the sessions of the conference are now available online