16.6. Start

16.6.1. Node by id
16.6.2. Relationship by id
16.6.3. Multiple nodes by id
16.6.4. All nodes
16.6.5. Node by index lookup
16.6.6. Relationship by index lookup
16.6.7. Node by index query
16.6.8. Multiple start points

Every query describes a pattern, and in that pattern one can have multiple start points. A start point is a relationship or a node that form the starting points for a pattern match. You can either introduce start points by id, or by index lookups. Note that trying to use an index that doesn’t exist will throw an exception.

Graph

cypher-start-graph.svg

16.6.1. Node by id

Binding a node as a start point is done with the node(*) function .

Query

START n=node(1)
RETURN n

The corresponding node is returned

Result

n
1 row, 1 ms

Node[1]{name->"A"}


16.6.2. Relationship by id

Binding a relationship as a start point is done with the relationship() function, which can also be abbreviated rel().

Query

START r=relationship(0)
RETURN r

The relationship with id 0 is returned

Result

r
1 row, 0 ms

:KNOWS[0] {}


16.6.3. Multiple nodes by id

Multiple nodes are selected by listing them separated by commas.

Query

START n=node(1, 2, 3)
RETURN n

The nodes listed in the START statement.

Result

n
3 rows, 1 ms

Node[1]{name->"A"}

Node[2]{name->"B"}

Node[3]{name->"C"}


16.6.4. All nodes

To get all the nodes, use an asterisk. This can be done with relationships as well.

Query

START n=node(*)
RETURN n

This query returns all the nodes in the graph.

Result

n
3 rows, 0 ms

Node[1]{name->"A"}

Node[2]{name->"B"}

Node[3]{name->"C"}


16.6.5. Node by index lookup

If the start point can be found by index lookups, it can be done like this: node:index-name(key = "value"). In this example, there exists a node index named nodes.

Query

START n=node:nodes(name = "A")
RETURN n

The node indexed with name "A" is returned

Result

n
1 row, 0 ms

Node[1]{name->"A"}


16.6.6. Relationship by index lookup

If the start point can be found by index lookups, it can be done like this: relationship:index-name(key = "value"].

Query

START r=relationship:rels(property = "some_value")
RETURN r

The relationship indexed with property "some_value" is returned

Result

r
1 row, 0 ms

:KNOWS[0] {property->"some_value"}


16.6.7. Node by index query

If the start point can be found by index more complex lucene queries: node:index-name("query").This allows you to write more advanced index queries

Query

START n=node:nodes("name:A")
RETURN n

The node indexed with name "A" is returned

Result

n
1 row, 1 ms

Node[1]{name->"A"}


16.6.8. Multiple start points

Sometimes you want to bind multiple start points. Just list them separated by commas.

Query

START a=node(1), b=node(2)
RETURN a,b

Both the A and the B node are returned

Result

ab
1 row, 0 ms

Node[1]{name->"A"}

Node[2]{name->"B"}