Skip to content

Instantly share code, notes, and snippets.

@quagly
Last active December 20, 2015 08:09
Show Gist options
  • Save quagly/6098943 to your computer and use it in GitHub Desktop.
Save quagly/6098943 to your computer and use it in GitHub Desktop.
= graphGist generated from spock test Neo4jCypherOneNode.groovy
graphGist asciiDoc file for use at http://gist.neo4j.org/ [GitHub Gist]
Generated on Sun Jul 28 08:03:44 PDT 2013
//console
query to create one node with one property
[source,cypher]
----
CREATE (n {name : 'Immanuel'})
----
//table
query to add property to node
[source,cypher]
----
START n=node(*)
WHERE n.name! = 'Immanuel'
SET n.lastName = 'Kant'
RETURN n as kant
----
//table
query to add and remove property from node
[source,cypher]
----
START n=node(*)
WHERE n.name! = 'Immanuel'
SET n.firstName = 'Immanuel'
REMOVE n.name
RETURN n as kant
----
//table
query to filter with AND HAS and RegEx
[source,cypher]
----
START n=node(*)
WHERE
HAS(n.firstName) // test existence
AND n.firstName! = 'Immanuel' // test not Null and equal
AND n.lastName =~ '^K.*' // RegEx
AND n.firstName =~ '(?i)immANuEl' // case insensitive RegEx
AND n.lastName IN [ 'Kant', 'Kan', 'NoIKant', 'YesIKan' ] // in list
RETURN n as kant
----
//table
query to delete node
[source,cypher]
----
START n=node(*)
WHERE n.firstName! = 'Immanuel'
DELETE n
----
//table
@peterneubauer
Copy link

Updated to new Cypher syntax, see https://gist.github.com/peterneubauer/6363731

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment