Reputation: 1
I was trying to run a query in Neo4j to make a relationship between a recipe and ingredients:
MATCH (spongeCake:Cake {name: "Sponge Cake"}),
(white:Flour {name: "white"}),
(egg:Ingredient {name: "egg"}),
(butter:Ingredient {name: "butter"}),
(milk:Ingredient {name: "milk"}),
(sugar:Ingredient {name: "sugar"}),
(brown:Flour {name: "brown"}),
MERGE (spongeCake)-[r:CONTAINS {quantity: 4, unit: "medium"}]->(egg),
(spongeCake)-[r:CONTAINS {quantity: 50, unit: "grams"}]->(brown),
(spongeCake)-[r:CONTAINS {quantity: 255, unit: "grams"}]->(sugar),
(spongeCake)-[r:CONTAINS {quantity: 25, unit: "grams"}]->(milk),
(spongeCake)-[r:CONTAINS {quantity: 300, unit: "grams"}]->(white),
(spongeCake)-[r:CONTAINS {quantity: 45, unit: "grams"}]->(butter);
For some reason MERGE is giving me a lot of trouble and I am getting the following error:
Invalid input 'MERGE': expected "(", "allShortestPaths" or "shortestPath" (line 9, column 1 (offset: 250))
"MERGE (spongeCake)-[r:CONTAINS {quantity: 4, unit: "medium"}]->(egg)"
^
How can I do this correctly?
Upvotes: 0
Views: 97
Reputation: 12684
This is the syntax of what you want to achieve.
Learn the syntax well. Goodluck!
..
MATCH (spongeCake:Cake {name: "Sponge Cake"})
MATCH (white:Flour {name: "white"})
MATCH (egg:Ingredient {name: "egg"}),
MATCH (butter:Ingredient {name: "butter"})
MATCH (milk:Ingredient {name: "milk"})
MATCH (sugar:Ingredient {name: "sugar"})
MATCH (brown:Flour {name: "brown"})
MERGE (spongeCake)-[:CONTAINS {quantity: 4, unit: "medium"}]->(egg)
MERGE (spongeCake)-[:CONTAINS {quantity: 50, unit: "grams"}]->(brown)
MERGE (spongeCake)-[:CONTAINS {quantity: 255, unit: "grams"}]->(sugar)
MERGE (spongeCake)-[:CONTAINS {quantity: 25, unit: "grams"}]->(milk)
MERGE (spongeCake)-[:CONTAINS {quantity: 300, unit: "grams"}]->(white)
MERGE (spongeCake)-[:CONTAINS {quantity: 45, unit: "grams"}]->(butter)
RETURN spongeCake
Upvotes: 1