Skip to content

Instantly share code, notes, and snippets.

@chrisvest
Last active December 27, 2015 12:29
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 chrisvest/7326564 to your computer and use it in GitHub Desktop.
Save chrisvest/7326564 to your computer and use it in GitHub Desktop.
neo4j-sh (?)$ create (a:Person {x:1}), (b:Person {x:2}), (c:Person {x:3});
+-------------------+
| No data returned. |
+-------------------+
Nodes created: 3
Properties set: 3
Labels added: 3
1079 ms
neo4j-sh (?)$ profile match (p:Person {x:2}) return p;
+--------------+
| p            |
+--------------+
| Node[1]{x:2} |
+--------------+
1 row

Filter(pred="Property(p,x(0)) == Literal(2)", _rows=1, _db_hits=3)
NodeByLabel(label="Person", identifier="p", _rows=3, _db_hits=0)
neo4j-sh (?)$ create constraint on (p:Person) assert p.x is unique;
+-------------------+
| No data returned. |
+-------------------+
Constraints added: 1
50 ms
neo4j-sh (?)$ profile match (p:Person {x:2}) return p;             
+--------------+
| p            |
+--------------+
| Node[1]{x:2} |
+--------------+
1 row

SchemaIndex(identifier="p", _db_hits=0, _rows=1, label="Person", query="Literal(2)", property="x")
neo4j-sh (?)$ match (a:Person {x:1}), (b:Person {x:2}) create unique (a)-[:R]->(b), (a)-[:R]->(b);
+-------------------+
| No data returned. |
+-------------------+
Relationships created: 2
279 ms
neo4j-sh (?)$ match (a:Person {x:1})-[r]->() return r;
+---------+
| r       |
+---------+
| :R[0]{} |
| :R[1]{} |
+---------+
2 rows
75 ms
neo4j-sh (?)$

It might be a bug that we're creating two relationships here with CREATE UNIQUE.

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