Skip to content

Instantly share code, notes, and snippets.

@mneedham
Created May 25, 2013 12:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mneedham/5648898 to your computer and use it in GitHub Desktop.
Save mneedham/5648898 to your computer and use it in GitHub Desktop.
// Initial products
CREATE (dress1 { name: "Halter Dress", colour: "Blue"})-[:BRAND]-(frenchConnection { name: "French Connection" })
CREATE (dress2 { name: "Another Dress", colour: "Yellow"})-[:BRAND]-(frenchConnection)
CREATE (dress3 { name: "Different Dress", colour: "Blue"})-[:BRAND]-(frenchConnection)
RETURN dress1, dress2, dress3
// Query to find the blue French Connection products
START brand = node:node_auto_index(name="French Connection")
MATCH brand<-[:BRAND]-product
WHERE product.colour = "Blue"
RETURN brand, product
// Create a node for the colour 'Blue'
CREATE (blue { name: "Blue"})
// Make all the blue French Connection products point to the blue node
START brand = node:node_auto_index(name="French Connection"), blue = node:node_auto_index(name="Blue")
MATCH brand<-[:BRAND]-product
WHERE product.colour = "Blue"
CREATE UNIQUE product-[:COLOUR]->blue
RETURN brand, product
// Create a node for the colour 'Yellow'
CREATE (yellow { name: "Yellow"})
// Make all the yellow French Connection products point to the blue node
START brand = node:node_auto_index(name="French Connection") , yellow = node:node_auto_index(name="Yellow")
MATCH brand<-[:BRAND]-product
WHERE product.colour = "Yellow"
CREATE product-[:COLOUR]->yellow
RETURN brand, product
// Query for all the blue French Connection products
START brand = node:node_auto_index(name="French Connection"), blue = node:node_auto_index(name="Blue")
MATCH brand<-[:BRAND]-product-[:COLOUR]->blue
RETURN brand, product
// Add an on sale property to all French connection blue products
START brand = node:node_auto_index(name="French Connection"),
blue = node:node_auto_index(name="Blue")
MATCH brand<-[:BRAND]-product-[:COLOUR]->blue
SET product.state = "OnSale"
RETURN brand, product
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment