Legend
Read |
Write |
General |
Functions |
Schema |
Performance |
Syntax
Read Query Structure |
---|
[MATCH WHERE] [OPTIONAL MATCH WHERE] [WITH [ORDER BY] [SKIP] [LIMIT]] RETURN [ORDER BY] [SKIP] [LIMIT] |
MATCH |
---|
MATCH (n:Person)-[:KNOWS]->(m:Person) WHERE n.name = 'Alice' Node patterns can contain labels and properties. |
MATCH (n)-->(m) Any pattern can be used in |
MATCH (n {name: 'Alice'})-->(m) Patterns with node properties. |
MATCH p = (n)-->(m) Assign a path to |
OPTIONAL MATCH (n)-[r]->(m) Optional pattern: |
WHERE |
---|
WHERE n.property <> $value Use a predicate to filter.
Note that |
RETURN |
---|
RETURN * Return the value of all variables. |
RETURN n AS columnName Use alias for result column name. |
RETURN DISTINCT n Return unique rows. |
ORDER BY n.property Sort the result. |
ORDER BY n.property DESC Sort the result in descending order. |
SKIP $skipNumber Skip a number of results. |
LIMIT $limitNumber Limit the number of results. |
SKIP $skipNumber LIMIT $limitNumber Skip results at the top and limit the number of results. |
RETURN count(*) The number of matching rows. See Aggregating Functions for more. |
WITH |
---|
MATCH (user)-[:FRIEND]-(friend) WHERE user.name = $name WITH user, count(friend) AS friends WHERE friends > 10 RETURN user The |
MATCH (user)-[:FRIEND]-(friend) WITH user, count(friend) AS friends ORDER BY friends DESC SKIP 1 LIMIT 3 RETURN user
|
UNION |
---|
MATCH (a)-[:KNOWS]->(b) RETURN b.name UNION MATCH (a)-[:LOVES]->(b) RETURN b.name Returns the distinct union of all query results. Result column types and names have to match. |
MATCH (a)-[:KNOWS]->(b) RETURN b.name UNION ALL MATCH (a)-[:LOVES]->(b) RETURN b.name Returns the union of all query results, including duplicated rows. |
Write-Only Query Structure |
---|
(CREATE [UNIQUE] | MERGE)* [SET|DELETE|REMOVE|FOREACH]* [RETURN [ORDER BY] [SKIP] [LIMIT]] |
Read-Write Query Structure |
---|
[MATCH WHERE] [OPTIONAL MATCH WHERE] [WITH [ORDER BY] [SKIP] [LIMIT]] (CREATE [UNIQUE] | MERGE)* [SET|DELETE|REMOVE|FOREACH]* [RETURN [ORDER BY] [SKIP] [LIMIT]] |
CREATE |
---|
CREATE (n {name: $value}) Create a node with the given properties. |
CREATE (n $map) Create a node with the given properties. |
UNWIND $listOfMaps AS properties CREATE (n) SET n = properties Create nodes with the given properties. |
CREATE (n)-[r:KNOWS]->(m) Create a relationship with the given type and direction; bind a variable to it. |
CREATE (n)-[:LOVES {since: $value}]->(m) Create a relationship with the given type, direction, and properties. |
SET |
---|
SET n.property1 = $value1, n.property2 = $value2 Update or create a property. |
SET n = $map Set all properties. This will remove any existing properties. |
SET n += $map Add and update properties, while keeping existing ones. |
SET n:Person Adds a label |
MERGE |
---|
MERGE (n:Person {name: $value}) ON CREATE SET n.created = timestamp() ON MATCH SET n.counter = coalesce(n.counter, 0) + 1, n.accessTime = timestamp() Match a pattern or create it if it does not exist.
Use |
MATCH (a:Person {name: $value1}), (b:Person {name: $value2}) MERGE (a)-[r:LOVES]->(b)
|
MATCH (a:Person {name: $value1}) MERGE (a)-[r:KNOWS]->(b:Person {name: $value3})
|
DELETE |
---|
DELETE n, r Delete a node and a relationship. |
DETACH DELETE n Delete a node and all relationships connected to it. |
MATCH (n) DETACH DELETE n Delete all nodes and relationships from the database. |
REMOVE |
---|
REMOVE n:Person Remove a label from |
REMOVE n.property Remove a property. |
FOREACH |
---|
FOREACH (r IN relationships(path) | SET r.marked = true) Execute a mutating operation for each relationship in a path. |
FOREACH (value IN coll | CREATE (:Person {name: value})) Execute a mutating operation for each element in a list. |
CALL |
---|
CALL db.labels() YIELD label This shows a standalone call to the built-in procedure |
CALL java.stored.procedureWithArgs Standalone calls may omit |
CALL db.labels() YIELD label RETURN count(label) AS count Calls the built-in procedure |
Import |
---|
LOAD CSV FROM 'https://neo4j.com/docs/cypher-refcard/3.2/csv/artists.csv' AS line CREATE (:Artist {name: line[1], year: toInteger(line[2])}) Load data from a CSV file and create nodes. |
LOAD CSV WITH HEADERS FROM 'https://neo4j.com/docs/cypher-refcard/3.2/csv/artists-with-headers.csv' AS line CREATE (:Artist {name: line.Name, year: toInteger(line.Year)}) Load CSV data which has headers. |
USING PERIODIC COMMIT 500 LOAD CSV WITH HEADERS FROM 'https://neo4j.com/docs/cypher-refcard/3.2/csv/artists-with-headers.csv' AS line CREATE (:Artist {name: line.Name, year: toInteger(line.Year)}) Commit the current transaction after every 500 rows when importing large amounts of data. |
LOAD CSV FROM 'https://neo4j.com/docs/cypher-refcard/3.2/csv/artists-fieldterminator.csv' AS line FIELDTERMINATOR ';' CREATE (:Artist {name: line[1], year: toInteger(line[2])}) Use a different field terminator, not the default which is a comma (with no whitespace around it). |
Operators | |
---|---|
General |
|
Mathematical |
|
Comparison |
|
Boolean |
|
String |
|
List |
|
Regular Expression |
|
String matching |
|
null |
---|
|
Patterns |
---|
(n:Person) Node with |
(n:Person:Swedish) Node with both |
(n:Person {name: $value}) Node with the declared properties. |
()-[r {name: $value}]-() Matches relationships with the declared properties. |
(n)-->(m) Relationship from |
(n)--(m) Relationship in any direction between |
(n:Person)-->(m) Node |
(m)<-[:KNOWS]-(n) Relationship of type |
(n)-[:KNOWS|:LOVES]->(m) Relationship of type |
(n)-[r]->(m) Bind the relationship to variable |
(n)-[*1..5]->(m) Variable length path of between 1 and 5 relationships from |
(n)-[*]->(m) Variable length path of any number of relationships from |
(n)-[:KNOWS]->(m {property: $value}) A relationship of type |
shortestPath((n1:Person)-[*..6]-(n2:Person)) Find a single shortest path. |
allShortestPaths((n1:Person)-[*..6]->(n2:Person)) Find all shortest paths. |
size((n)-->()-->()) Count the paths matching the pattern. |
Labels |
---|
CREATE (n:Person {name: $value}) Create a node with label and property. |
MERGE (n:Person {name: $value}) Matches or creates unique node(s) with the label and property. |
SET n:Spouse:Parent:Employee Add label(s) to a node. |
MATCH (n:Person) Matches nodes labeled |
MATCH (n:Person) WHERE n.name = $value Matches nodes labeled |
WHERE (n:Person) Checks the existence of the label on the node. |
labels(n) Labels of the node. |
REMOVE n:Person Remove the label from the node. |
Lists |
---|
['a', 'b', 'c'] AS list Literal lists are declared in square brackets. |
size($list) AS len, $list[0] AS value Lists can be passed in as parameters. |
range($firstNum, $lastNum, $step) AS list
|
MATCH p = (a)-[:KNOWS*]->() RETURN relationships(p) AS r The list of relationships comprising a variable length path can be returned using named paths and |
RETURN matchedNode.list[0] AS value, size(matchedNode.list) AS len Properties can be lists of strings, numbers or booleans. |
list[$idx] AS value, list[$startIdx..$endIdx] AS slice List elements can be accessed with |
UNWIND $names AS name MATCH (n {name: name}) RETURN avg(n.age) With |
MATCH (a) RETURN [(a)-->(b) WHERE b.name = 'Bob' | b.age] Pattern comprehensions may be used to do a custom projection from a match directly into a list. |
MATCH (person) RETURN person { .name, .age} Map projections may be easily constructed from nodes, relationships and other map values. |
Maps |
---|
{name: 'Alice', age: 38, address: {city: 'London', residential: true}} Literal maps are declared in curly braces much like property maps. Lists are supported. |
WITH {person: {name: 'Anne', age: 25}} AS p RETURN p.person.name Access the property of a nested map. |
MERGE (p:Person {name: $map.name}) ON CREATE SET p = $map Maps can be passed in as parameters and used either as a map or by accessing keys. |
MATCH (matchedNode:Person) RETURN matchedNode Nodes and relationships are returned as maps of their data. |
map.name, map.age, map.children[0] Map entries can be accessed by their keys. Invalid keys result in an error. |
Predicates |
---|
n.property <> $value Use comparison operators. |
exists(n.property) Use functions. |
n.number >= 1 AND n.number <= 10 Use boolean operators to combine predicates. |
1 <= n.number <= 10 Use chained operators to combine predicates. |
n:Person Check for node labels. |
variable IS NULL Check if something is |
NOT exists(n.property) OR n.property = $value Either the property does not exist or the predicate is |
n.property = $value Non-existing property returns |
n["property"] = $value Properties may also be accessed using a dynamically computed property name. |
n.property STARTS WITH 'Tob' OR n.property ENDS WITH 'n' OR n.property CONTAINS 'goodie' String matching. |
n.property =~ 'Tob.*' String regular expression matching. |
(n)-[:KNOWS]->(m) Ensure the pattern has at least one match. |
NOT (n)-[:KNOWS]->(m) Exclude matches to |
n.property IN [$value1, $value2] Check if an element exists in a list. |
List Predicates |
---|
all(x IN coll WHERE exists(x.property)) Returns |
any(x IN coll WHERE exists(x.property)) Returns |
none(x IN coll WHERE exists(x.property)) Returns |
single(x IN coll WHERE exists(x.property)) Returns |
CASE |
---|
CASE n.eyes WHEN 'blue' THEN 1 WHEN 'brown' THEN 2 ELSE 3 END Return |
CASE WHEN n.eyes = 'blue' THEN 1 WHEN n.age < 40 THEN 2 ELSE 3 END Return |
List Expressions |
---|
size($list) Number of elements in the list. |
reverse($list) Reverse the order of the elements in the list. |
head($list), last($list), tail($list)
|
[x IN list WHERE x.prop <> $value | x.prop] Combination of filter and extract in a concise notation. |
extract(x IN list | x.prop) A list of the value of the expression for each element in the original list. |
filter(x IN list WHERE x.prop <> $value) A filtered list of the elements where the predicate is |
reduce(s = "", x IN list | s + x.prop) Evaluate expression for each element in the list, accumulate the results. |
Functions |
---|
coalesce(n.property, $defaultValue) The first non- |
timestamp() Milliseconds since midnight, January 1, 1970 UTC. |
id(nodeOrRelationship) The internal id of the relationship or node. |
toInteger($expr) Converts the given input into an integer if possible; otherwise it returns |
toFloat($expr) Converts the given input into a floating point number if possible; otherwise it returns |
toBoolean($expr) Converts the given input into a boolean if possible; otherwise it returns |
keys($expr) Returns a list of string representations for the property names of a node, relationship, or map. |
properties({expr}) Returns a map containing all the properties of a node or relationship. |
Path Functions |
---|
length(path) The number of relationships in the path. |
nodes(path) The nodes in the path as a list. |
relationships(path) The relationships in the path as a list. |
extract(x IN nodes(path) | x.prop) Extract properties from the nodes in a path. |
Spatial Functions |
---|
point({x: {x}, y: {y}}) Returns a point in a 2D coordinate system. |
distance(point({x: {x1}, y: {y1}}), point({x: {x2}, y: {y2}})) Returns a floating point number representing the geodesic distance between two points. |
Mathematical Functions |
---|
abs($expr) The absolute value. |
rand() Returns a random number in the range from 0 (inclusive) to 1 (exclusive), |
round($expr) Round to the nearest integer; |
sqrt($expr) The square root. |
sign($expr)
|
sin($expr) Trigonometric functions also include |
degrees($expr), radians($expr), pi() Converts radians into degrees; use |
log10($expr), log($expr), exp($expr), e() Logarithm base 10, natural logarithm, |
String Functions |
---|
toString($expression) String representation of the expression. |
replace($original, $search, $replacement) Replace all occurrences of |
substring($original, $begin, $subLength) Get part of a string.
The |
left($original, $subLength), right($original, $subLength) The first part of a string. The last part of the string. |
trim($original), lTrim($original), rTrim($original) Trim all whitespace, or on the left or right side. |
toUpper($original), toLower($original) UPPERCASE and lowercase. |
split($original, $delimiter) Split a string into a list of strings. |
reverse($original) Reverse a string. |
size($string) Calculate the number of characters in the string. |
Relationship Functions |
---|
type(a_relationship) String representation of the relationship type. |
startNode(a_relationship) Start node of the relationship. |
endNode(a_relationship) End node of the relationship. |
id(a_relationship) The internal id of the relationship. |
Aggregating Functions |
---|
count(*) The number of matching rows. |
count(variable) The number of non- |
count(DISTINCT variable) All aggregating functions also take the |
collect(n.property) List from the values, ignores |
sum(n.property) Sum numerical values. Similar functions are |
percentileDisc(n.property, $percentile) Discrete percentile. Continuous percentile is |
stDev(n.property) Standard deviation for a sample of a population.
For an entire population use |
INDEX |
---|
CREATE INDEX ON :Person(name) Create an index on the label |
MATCH (n:Person) WHERE n.name = $value An index can be automatically used for the equality comparison.
Note that for example |
MATCH (n:Person) WHERE n.name IN [$value] An index can automatically be used for the |
MATCH (n:Person) USING INDEX n:Person(name) WHERE n.name = $value Index usage can be enforced when Cypher uses a suboptimal index, or more than one index should be used. |
DROP INDEX ON :Person(name) Drop the index on the label |
CONSTRAINT |
---|
CREATE CONSTRAINT ON (p:Person) ASSERT p.name IS UNIQUE Create a unique property constraint on the label |
DROP CONSTRAINT ON (p:Person) ASSERT p.name IS UNIQUE Drop the unique constraint and index on the label |
CREATE CONSTRAINT ON (p:Person) ASSERT exists(p.name) (★) Create a node property existence constraint on the label |
DROP CONSTRAINT ON (p:Person) ASSERT exists(p.name) (★) Drop the node property existence constraint on the label |
CREATE CONSTRAINT ON ()-[l:LIKED]-() ASSERT exists(l.when) (★) Create a relationship property existence constraint on the type |
DROP CONSTRAINT ON ()-[l:LIKED]-() ASSERT exists(l.when) (★) Drop the relationship property existence constraint on the type |
CREATE CONSTRAINT ON (p:Person) ASSERT (p.firstname, p.surname) IS NODE KEY (★) Create a Node Key constraint on the label |
DROP CONSTRAINT ON (p:Person) ASSERT (p.firstname, p.surname) IS NODE KEY (★) Drop the Node Key constraint on the label |
Performance |
---|
|
RETURN |
---|
RETURN * Return the value of all variables. |
RETURN n AS columnName Use alias for result column name. |
RETURN DISTINCT n Return unique rows. |
ORDER BY n.property Sort the result. |
ORDER BY n.property DESC Sort the result in descending order. |
SKIP $skipNumber Skip a number of results. |
LIMIT $limitNumber Limit the number of results. |
SKIP $skipNumber LIMIT $limitNumber Skip results at the top and limit the number of results. |
RETURN count(*) The number of matching rows. See Aggregating Functions for more. |
WITH |
---|
MATCH (user)-[:FRIEND]-(friend) WHERE user.name = $name WITH user, count(friend) AS friends WHERE friends > 10 RETURN user The |
MATCH (user)-[:FRIEND]-(friend) WITH user, count(friend) AS friends ORDER BY friends DESC SKIP 1 LIMIT 3 RETURN user
|
UNION |
---|
MATCH (a)-[:KNOWS]->(b) RETURN b.name UNION MATCH (a)-[:LOVES]->(b) RETURN b.name Returns the distinct union of all query results. Result column types and names have to match. |
MATCH (a)-[:KNOWS]->(b) RETURN b.name UNION ALL MATCH (a)-[:LOVES]->(b) RETURN b.name Returns the union of all query results, including duplicated rows. |
MERGE |
---|
MERGE (n:Person {name: $value}) ON CREATE SET n.created = timestamp() ON MATCH SET n.counter = coalesce(n.counter, 0) + 1, n.accessTime = timestamp() Match a pattern or create it if it does not exist.
Use |
MATCH (a:Person {name: $value1}), (b:Person {name: $value2}) MERGE (a)-[r:LOVES]->(b)
|
MATCH (a:Person {name: $value1}) MERGE (a)-[r:KNOWS]->(b:Person {name: $value3})
|
DELETE |
---|
DELETE n, r Delete a node and a relationship. |
DETACH DELETE n Delete a node and all relationships connected to it. |
MATCH (n) DETACH DELETE n Delete all nodes and relationships from the database. |
REMOVE |
---|
REMOVE n:Person Remove a label from |
REMOVE n.property Remove a property. |
FOREACH |
---|
FOREACH (r IN relationships(path) | SET r.marked = true) Execute a mutating operation for each relationship in a path. |
FOREACH (value IN coll | CREATE (:Person {name: value})) Execute a mutating operation for each element in a list. |
CALL |
---|
CALL db.labels() YIELD label This shows a standalone call to the built-in procedure |
CALL java.stored.procedureWithArgs Standalone calls may omit |
CALL db.labels() YIELD label RETURN count(label) AS count Calls the built-in procedure |
Spatial Functions |
---|
point({x: {x}, y: {y}}) Returns a point in a 2D coordinate system. |
distance(point({x: {x1}, y: {y1}}), point({x: {x2}, y: {y2}})) Returns a floating point number representing the geodesic distance between two points. |
Mathematical Functions |
---|
abs($expr) The absolute value. |
rand() Returns a random number in the range from 0 (inclusive) to 1 (exclusive), |
round($expr) Round to the nearest integer; |
sqrt($expr) The square root. |
sign($expr)
|
sin($expr) Trigonometric functions also include |
degrees($expr), radians($expr), pi() Converts radians into degrees; use |
log10($expr), log($expr), exp($expr), e() Logarithm base 10, natural logarithm, |
Relationship Functions |
---|
type(a_relationship) String representation of the relationship type. |
startNode(a_relationship) Start node of the relationship. |
endNode(a_relationship) End node of the relationship. |
id(a_relationship) The internal id of the relationship. |
Operators | |
---|---|
General |
|
Mathematical |
|
Comparison |
|
Boolean |
|
String |
|
List |
|
Regular Expression |
|
String matching |
|
null |
---|
|
Patterns |
---|
(n:Person) Node with |
(n:Person:Swedish) Node with both |
(n:Person {name: $value}) Node with the declared properties. |
()-[r {name: $value}]-() Matches relationships with the declared properties. |
(n)-->(m) Relationship from |
(n)--(m) Relationship in any direction between |
(n:Person)-->(m) Node |
(m)<-[:KNOWS]-(n) Relationship of type |
(n)-[:KNOWS|:LOVES]->(m) Relationship of type |
(n)-[r]->(m) Bind the relationship to variable |
(n)-[*1..5]->(m) Variable length path of between 1 and 5 relationships from |
(n)-[*]->(m) Variable length path of any number of relationships from |
(n)-[:KNOWS]->(m {property: $value}) A relationship of type |
shortestPath((n1:Person)-[*..6]-(n2:Person)) Find a single shortest path. |
allShortestPaths((n1:Person)-[*..6]->(n2:Person)) Find all shortest paths. |
size((n)-->()-->()) Count the paths matching the pattern. |
Lists |
---|
['a', 'b', 'c'] AS list Literal lists are declared in square brackets. |
size($list) AS len, $list[0] AS value Lists can be passed in as parameters. |
range($firstNum, $lastNum, $step) AS list
|
MATCH p = (a)-[:KNOWS*]->() RETURN relationships(p) AS r The list of relationships comprising a variable length path can be returned using named paths and |
RETURN matchedNode.list[0] AS value, size(matchedNode.list) AS len Properties can be lists of strings, numbers or booleans. |
list[$idx] AS value, list[$startIdx..$endIdx] AS slice List elements can be accessed with |
UNWIND $names AS name MATCH (n {name: name}) RETURN avg(n.age) With |
MATCH (a) RETURN [(a)-->(b) WHERE b.name = 'Bob' | b.age] Pattern comprehensions may be used to do a custom projection from a match directly into a list. |
MATCH (person) RETURN person { .name, .age} Map projections may be easily constructed from nodes, relationships and other map values. |
String Functions |
---|
toString($expression) String representation of the expression. |
replace($original, $search, $replacement) Replace all occurrences of |
substring($original, $begin, $subLength) Get part of a string.
The |
left($original, $subLength), right($original, $subLength) The first part of a string. The last part of the string. |
trim($original), lTrim($original), rTrim($original) Trim all whitespace, or on the left or right side. |
toUpper($original), toLower($original) UPPERCASE and lowercase. |
split($original, $delimiter) Split a string into a list of strings. |
reverse($original) Reverse a string. |
size($string) Calculate the number of characters in the string. |
Performance |
---|
|
Labels |
---|
CREATE (n:Person {name: $value}) Create a node with label and property. |
MERGE (n:Person {name: $value}) Matches or creates unique node(s) with the label and property. |
SET n:Spouse:Parent:Employee Add label(s) to a node. |
MATCH (n:Person) Matches nodes labeled |
MATCH (n:Person) WHERE n.name = $value Matches nodes labeled |
WHERE (n:Person) Checks the existence of the label on the node. |
labels(n) Labels of the node. |
REMOVE n:Person Remove the label from the node. |
Maps |
---|
{name: 'Alice', age: 38, address: {city: 'London', residential: true}} Literal maps are declared in curly braces much like property maps. Lists are supported. |
WITH {person: {name: 'Anne', age: 25}} AS p RETURN p.person.name Access the property of a nested map. |
MERGE (p:Person {name: $map.name}) ON CREATE SET p = $map Maps can be passed in as parameters and used either as a map or by accessing keys. |
MATCH (matchedNode:Person) RETURN matchedNode Nodes and relationships are returned as maps of their data. |
map.name, map.age, map.children[0] Map entries can be accessed by their keys. Invalid keys result in an error. |
Predicates |
---|
n.property <> $value Use comparison operators. |
exists(n.property) Use functions. |
n.number >= 1 AND n.number <= 10 Use boolean operators to combine predicates. |
1 <= n.number <= 10 Use chained operators to combine predicates. |
n:Person Check for node labels. |
variable IS NULL Check if something is |
NOT exists(n.property) OR n.property = $value Either the property does not exist or the predicate is |
n.property = $value Non-existing property returns |
n["property"] = $value Properties may also be accessed using a dynamically computed property name. |
n.property STARTS WITH 'Tob' OR n.property ENDS WITH 'n' OR n.property CONTAINS 'goodie' String matching. |
n.property =~ 'Tob.*' String regular expression matching. |
(n)-[:KNOWS]->(m) Ensure the pattern has at least one match. |
NOT (n)-[:KNOWS]->(m) Exclude matches to |
n.property IN [$value1, $value2] Check if an element exists in a list. |
List Predicates |
---|
all(x IN coll WHERE exists(x.property)) Returns |
any(x IN coll WHERE exists(x.property)) Returns |
none(x IN coll WHERE exists(x.property)) Returns |
single(x IN coll WHERE exists(x.property)) Returns |
CASE |
---|
CASE n.eyes WHEN 'blue' THEN 1 WHEN 'brown' THEN 2 ELSE 3 END Return |
CASE WHEN n.eyes = 'blue' THEN 1 WHEN n.age < 40 THEN 2 ELSE 3 END Return |
List Expressions |
---|
size($list) Number of elements in the list. |
reverse($list) Reverse the order of the elements in the list. |
head($list), last($list), tail($list)
|
[x IN list WHERE x.prop <> $value | x.prop] Combination of filter and extract in a concise notation. |
extract(x IN list | x.prop) A list of the value of the expression for each element in the original list. |
filter(x IN list WHERE x.prop <> $value) A filtered list of the elements where the predicate is |
reduce(s = "", x IN list | s + x.prop) Evaluate expression for each element in the list, accumulate the results. |
INDEX |
---|
CREATE INDEX ON :Person(name) Create an index on the label |
MATCH (n:Person) WHERE n.name = $value An index can be automatically used for the equality comparison.
Note that for example |
MATCH (n:Person) WHERE n.name IN [$value] An index can automatically be used for the |
MATCH (n:Person) USING INDEX n:Person(name) WHERE n.name = $value Index usage can be enforced when Cypher uses a suboptimal index, or more than one index should be used. |
DROP INDEX ON :Person(name) Drop the index on the label |
CONSTRAINT |
---|
CREATE CONSTRAINT ON (p:Person) ASSERT p.name IS UNIQUE Create a unique property constraint on the label |
DROP CONSTRAINT ON (p:Person) ASSERT p.name IS UNIQUE Drop the unique constraint and index on the label |
CREATE CONSTRAINT ON (p:Person) ASSERT exists(p.name) (★) Create a node property existence constraint on the label |
DROP CONSTRAINT ON (p:Person) ASSERT exists(p.name) (★) Drop the node property existence constraint on the label |
CREATE CONSTRAINT ON ()-[l:LIKED]-() ASSERT exists(l.when) (★) Create a relationship property existence constraint on the type |
DROP CONSTRAINT ON ()-[l:LIKED]-() ASSERT exists(l.when) (★) Drop the relationship property existence constraint on the type |
CREATE CONSTRAINT ON (p:Person) ASSERT (p.firstname, p.surname) IS NODE KEY (★) Create a Node Key constraint on the label |
DROP CONSTRAINT ON (p:Person) ASSERT (p.firstname, p.surname) IS NODE KEY (★) Drop the Node Key constraint on the label |