10.4. Start

[Important]Important

The START clause should only be used when accessing legacy indexes (see Chapter 36, Legacy Indexing). In all other cases, use MATCH instead (see Section 10.1, “Match”).

In Cypher, every query describes a pattern, and in that pattern one can have multiple starting points. A starting point is a relationship or a node where a pattern is anchored. Using START you can only introduce starting points by legacy index lookups. Note that trying to use a legacy index that doesn’t exist will generate an error.

This is the graph the examples are using:

Figure 10.4. Graph

Get node or relationship from index

Node by index lookup

When the starting point can be found by using 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 query returns the node indexed with the name "A".

Result

n
1 row

Node[0]{name:"A"}

Relationship by index lookup

When the starting point can be found by using index lookups, it can be done like this: relationship:index-name(key = "value").

Query. 

START r=relationship:rels(name = "Andrés")
RETURN r

The relationship indexed with the name property set to "Andrés" is returned by the query.

Result

r
1 row

:KNOWS[0]{name:"Andrés"

Node by index query

When the starting point can be found by more complex Lucene queries, this is the syntax to use: 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 by the query.

Result

n
1 row

Node[0]{name:"A"}