Values and types
Cypher® provides first class support for a number of data types.
These fall into several categories which will be described in detail in the following subsections:
- Property types
-
Integer, Float, String, Boolean, Point, Date, Time, LocalTime, DateTime, LocalDateTime, and Duration.
- Structural types
-
Node, Relationship, and Path.
- Composite types
-
List and Map.
Property types
-
Can be returned from Cypher queries
-
Can be used as parameters
-
Can be stored as properties
-
Can be constructed with Cypher literals
The property types:
-
Number, an abstract type, which has the subtypes Integer and Float
-
String
-
Boolean
-
The spatial type Point
-
Temporal types: Date, Time, LocalTime, DateTime, LocalDateTime and Duration
The adjective numeric, when used in the context of describing Cypher functions or expressions, indicates that any type of Number applies (Integer or Float).
Homogeneous lists of simple types can also be stored as properties, although lists in general (see Composite types) cannot be stored.
Cypher also provides pass-through support for byte arrays, which can be stored as property values. Byte arrays are not considered a first class data type by Cypher, so do not have a literal representation.
Sorting of special characters
Strings that contain characters that do not belong to the Basic Multilingual Plane (BMP) can have inconsistent or non-deterministic ordering in Neo4j. BMP is a subset of all characters defined in Unicode. Expressed simply, it contains all common characters from all common languages. The most significant characters not in BMP are those belonging to the Supplementary Multilingual Plane or the Supplementary Ideographic Plane. Examples are:
|
Structural types
-
Can be returned from Cypher queries
-
Cannot be used as parameters
-
Cannot be stored as properties
-
Cannot be constructed with Cypher literals
The structural types:
-
Node
-
Id
-
Label(s)
Labels are not values but are a form of pattern syntax.
-
Map (of properties)
-
-
Relationship
-
Id
-
Type
-
Map (of properties)
-
Id of the start node
-
Id of the end node
-
-
Path, an alternating sequence of nodes and relationships
Nodes, relationships, and paths are returned as a result of pattern matching. In Neo4j, all relationships have a direction. However, you can have the notion of undirected relationships at query time. |
Composite types
-
Can be returned from Cypher queries
-
Can be used as parameters
-
Cannot be stored as properties
-
Can be constructed with Cypher literals
The composite types:
-
List, a heterogeneous, ordered collection of values, each of which has any property, structural or composite type.
-
Map, a heterogeneous, unordered collection of (Key, Value) pairs.
-
Key is a String
-
Value has any property, structural or composite type
-
Composite values can also contain |
Special care must be taken when using null
(see Working with null
).