4.5. Return

4.5.1. Return nodes
4.5.2. Return relationships
4.5.3. Relationship type
4.5.4. Return property
4.5.5. Identifier with uncommon characters
4.5.6. Optional properties

In the return part of your query, you define which parts of the pattern you are interested in. It can be nodes, relationships, or properties on these.

4.5.1. Return nodes

To return a node, list it in the return statemenet.

Query

start n=(2) return n

The node.

Result

 +--------------------+
 | n                  |
 +--------------------+
 | Node[2]{name->"B"} |
 +--------------------+
 1 rows, 0 ms

4.5.2. Return relationships

To return a relationship, just include it in the return list.

Query

start n=(1) match (n)-[r:KNOWS]->(c) return r

The relationship.

Result

 +--------------+
 | r            |
 +--------------+
 | :KNOWS[0] {} |
 +--------------+
 1 rows, 1 ms

4.5.3. Relationship type

When you want to output the relationship type, and not the whole relationship, you can use ~TYPE.

Query

start n=(1) match (n)-[r]->() return r~TYPE

The relationship type of r.

Result

 +--------+
 | r~TYPE |
 +--------+
 | KNOWS  |
 | BLOCKS |
 +--------+
 2 rows, 1 ms

4.5.4. Return property

To return a property, use the dot separator, like this:

Query

start n=(1) return n.name

The the value of the property name.

Result

 +--------+
 | n.name |
 +--------+
 | A      |
 +--------+
 1 rows, 0 ms

4.5.5. Identifier with uncommon characters

To introduce a placeholder that is made up of characters that are outside of the english alphabet, you can use the ` to enclose the identifier, like this:

Query

start `This isn't a common identifier`=(1)
return `This isn't a common identifier`.`<<!!__??>>`

The node indexed with name "A" is returned

Result

 +-------------------------------------------+
 | This isn't a common identifier.<<!!__??>> |
 +-------------------------------------------+
 | Yes!                                      |
 +-------------------------------------------+
 1 rows, 0 ms

4.5.6. Optional properties

If a property might or might not be there, you can select it optionally by adding a questionmark to the identifier, like this:

Query

start n=(1, 2) return n.age?

The age when the node has that property, or null if the property is not there.

Result

 +--------+
 | n.age  |
 +--------+
 | 55     |
 | <null> |
 +--------+
 2 rows, 1 ms