Values and types

This section provides an overview of data types in Cypher.

Cypher provides first class support for a number of data types. These fall into the following three categories: property, structural, and composite. This chapter will first provide a brief overview of each type, and then go into more detail about the property data type.

Property types

The following data types are included in the property types category: Integer, Float, String, Boolean, Point, Date, Time, LocalTime, DateTime, LocalDateTime, and Duration.

  • Property types can be returned from Cypher queries

  • Property types can be used as parameters

  • Property types can be stored as properties

  • Property types can be constructed with Cypher literals

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 supported for performance reasons, since using Cypher’s generic language type, List of Integer (where each Integer has a 64-bit representation), would be too costly. However, byte arrays are not considered a first class data type by Cypher, so they do not have a literal representation.

Structural types

The following data types are included in the structural types category: Node, Relationship, and Path.

  • Structural types can be returned from Cypher queries

  • Structural types cannot be used as parameters

  • Structural types cannot be stored as properties

  • Structural types cannot be constructed with Cypher literals

The Node data type includes: Id, Label(s), and Map (of properties). Note that labels are not values, but a form of pattern syntax.

The Relationship data type includes: Id, Type, Map (of properties), Id of start node, and Id of end node.

The Path data type is 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

The following data types are included in the composite types category: List and Map.

  • Composite types can be returned from Cypher queries

  • Composite types can be used as parameters

  • Composite types cannot be stored as properties

  • Composite types can be constructed with Cypher literals

The List data type is a heterogeneous, ordered collection of values, each of which can have any property, structural or composite type.

As noted above, homogeneous lists of simple types can be stored as properties.

The Map data type is a heterogeneous, unordered collection of (Key, Value) pairs, where Key is a string and Value can have any property, structural, or composite type.

Composite values can also contain null. For more details, see working with null.

Property type details

The below table provides more detailed information about the various property types that Cypher supports. Note that Cypher types are implemented using Java, and that below table references Java value constants.

Type Min. value Max. value Precision

Boolean

False

True

-

Date

-999_999_999-01-01

+999_999_999-12-31

Days

DateTime

-999_999_999-01-01T00:00:00+18:00

+999_999_999-12-31T23:59:59.999999999-18:00

Nanoseconds

Duration

P-292471208677Y-6M-15DT-15H-36M-32S

P292471208677Y6M15DT15H36M32.999999999S

Nanoseconds

Float

Double.MIN_VALUE [1]

Double.MAX_VALUE

64 bit

Integer

Long.MIN_VALUE

Long.MAX_VALUE

64 bit

LocalDateTime

-999_999_999-01-01T00:00:00

+999_999_999-12-31T23:59:59.999999999

Nanoseconds

LocalTime

00:00:00

23:59:59.999999999

Nanoseconds

Point

Cartesian: (-Double.MAX_VALUE, -Double.MAX_VALUE)

Cartesian_3D: (-Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE)

WGS_84: (-180, -90)

WGS_84_3D: (-180, -90, -Double.MAX_VALUE)

Cartesian: (Double.MAX_VALUE, Double.MAX_VALUE)

Cartesian_3D: (Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE)

WGS_84: (180, 90)

WGS_84_3D: (180, 90, Double.MAX_VALUE)

The precision of each coordinate of the Point is 64 bit as they are floats.

String

-

-

-

Time

00:00:00+18:00

23:59:59.999999999-18:00`

Nanoseconds

Java value details

Name Value

Double.MAX_VALUE

1.7976931348623157e+308

Double.MIN_VALUE

4.9e-324

Long.MAX_VALUE

2^63-1

Long.MIN_VALUE

-2^63


1. The minimum value represents the minimum positive value of a Float, i.e. the closest value to zero. It is also possible to have a negative Float.