You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: modules/ROOT/pages/values-and-types/ordering-equality-comparison.adoc
+56-6Lines changed: 56 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,7 +35,7 @@ For example, `1 > b` and `1 < b` are both `false` when `b` is NaN.
35
35
* String values are compared for ordering using lexicographic order (e.g. `"x" < "xy"`).
36
36
* Boolean values are compared for ordering such that `false < true`.
37
37
* When comparing values for ordering, if one of the arguments is `null`, the result is always `null`.
38
-
* xref:values-and-types/spatial.adoc[Spatial values] cannot be compared using the operators `\<=`, `<`,`>=`, `>`.
38
+
* xref:values-and-types/spatial.adoc[Spatial values] and xref:values-and-types/vector.adoc[`VECTOR`] values cannot be compared using the operators `\<=`, `<`,`>=`, `>`.
39
39
To compare spatial values within a specific range, use either the xref:functions/spatial.adoc#functions-withinBBox[`point.withinBBox()`] or the xref:functions/spatial.adoc#functions-point-wgs84-2d[`point()`] function.
40
40
41
41
[[value-hierarchy]]
@@ -146,11 +146,61 @@ If they have the same time and offset but different named time zones, they are s
146
146
Since the length of a day, month, or year varies, Cypher does not define a strict ordering for durations.
147
147
As a result, comparing two durations `(e.g, duration1 < duration2)` will always return `null`.
148
148
149
+
[role=label--new-2025.xx]
149
150
[[ordering-vector]]
150
-
=== Ordering vector values
151
+
=== Vector values
151
152
152
-
Similar to spatial values, vectors cannot be compared using the operators (<, >, >= and <=)
153
+
`VECTOR` values with a defined coordinate type and no dimension are ordered before values with only a defined dimension.
154
+
Values with both a defined coordinate type and dimension are ordered according to the ordering of the vector coordinate types, listed in ascending order below:
153
155
154
-
Vectors of different coordinate type values are ordered by the coordinate type, this means the current order is: INTEGER8, INTEGER16, INTEGER32, INTEGER64, FLOAT32, FLOAT64
155
-
Within the same coordinate type, vectors are then ordered by their dimension, with smaller first (e.g Vector(1024) before Vector(2048)).
156
-
Vectors of the same coordinate type and dimension are then ordered pairwise (similar to how lists are ordered e.g Vector([1, 2]) is ordered before a Vector([2, 1])).
156
+
* `INTEGER8`
157
+
* `INTEGER16`
158
+
* `INTEGER32`
159
+
* `INTEGER64`
160
+
* `FLOAT32`
161
+
* `FLOAT64`
162
+
163
+
Within the same coordinate type, `VECTOR` values are ordered by their dimension, with smaller values first.
164
+
`VECTOR` values of the same coordinate type and dimension are then ordered pairwise, similar to how `LIST` values are ordered.
165
+
166
+
.Ordering rules for `VECTOR` values
167
+
[cols="3,3,2,6", options="header"]
168
+
|===
169
+
| A | B | Ordered As | Reason
170
+
171
+
| `VECTOR<FLOAT32>(12345)`
172
+
| `VECTOR<FLOAT32>(123456)`
173
+
| A < B
174
+
| Same coordinate type, compare by dimension ascending.
175
+
176
+
| `VECTOR<INTEGER32>(1234)`
177
+
| `VECTOR<FLOAT32>(1234)`
178
+
| A < B
179
+
| Coordinate type order: `INTEGER32` < `FLOAT32`
180
+
181
+
| `VECTOR<INTEGER8>`
182
+
| `VECTOR(3)`
183
+
| A < B
184
+
| Coordinate type defined and no dimension < dimension defined and no coordinate type
185
+
186
+
| `VECTOR<INTEGER64>(123456)`
187
+
| `VECTOR<FLOAT32>(3)`
188
+
| A < B
189
+
| Coordinate type order: `INTEGER64` < `FLOAT32`, compare coordinate type first.
190
+
191
+
| `VECTOR<FLOAT64>(1234)`
192
+
| `VECTOR<FLOAT32>(1234)`
193
+
| B < A
194
+
| Coordinate type order: `FLOAT32` < `FLOAT64`
195
+
196
+
| `VECTOR<FLOAT32>([1, 2])`
197
+
| `VECTOR<FLOAT32>([2, 1])`
198
+
| A < B
199
+
| Same coordinate type and dimension, pairwise value comparison.
200
+
201
+
| `VECTOR<INTEGER16>(1234)`
202
+
| `LIST<INTEGER>`
203
+
| A < B
204
+
| `VECTOR` values are ordered before `LIST` values
0 commit comments