diff --git a/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc b/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc index 7e2276a36..7b8d6fd73 100644 --- a/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc +++ b/modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc @@ -22,6 +22,35 @@ Cypher 25 was introduced in Neo4j 2025.06 and can only be used on Neo4j 2025.06+ Features removed in Cypher 25 are still available on Neo4j 2025.06+ databases either by prepending a query with `CYPHER 5` or by having Cypher 5 as the default language for the database. For more information, see xref:queries/select-version.adoc[]. +[[cypher-deprecations-additions-removals-2025.11]] +== Neo4j 2025.11 + +=== Updated in Cypher 25 + +[cols="2", options="header"] +|=== +| Feature +| Details + +a| +label:functionality[] +label:new[] +[source, cypher, role="noheader"] +---- +RETURN coll.distinct([true, false, false, true, true, false]) +RETURN coll.flatten([1, [2]]), coll.flatten([false, ['a']], 2); +RETURN coll.indexOf(['A', 'new', 'function'], 'new'); +RETURN coll.insert([1, 2, 4], 2, 3); +RETURN coll.max([1.5, 2, 5.4, 0, 4]); +RETURN coll.min([1.5, 2, 5.4, 0, 4]); +RETURN coll.remove(['a', 'a', 'b', 'c', 'd'], 2); +RETURN coll.sort([3, 1, 4, 2, 'a', 'c', 'b']); +---- +| Introduction of eight new collection-based Cypher functions. +For more information, see xref:functions/list.adoc[List functions - lists]. + +|=== + [[cypher-deprecations-additions-removals-2025.10]] == Neo4j 2025.10 diff --git a/modules/ROOT/pages/functions/index.adoc b/modules/ROOT/pages/functions/index.adoc index fdba301a4..1432bdc04 100644 --- a/modules/ROOT/pages/functions/index.adoc +++ b/modules/ROOT/pages/functions/index.adoc @@ -128,6 +128,38 @@ Further details and examples of lists may be found in xref::values-and-types/lis | Function | Signature | Description +1.1+| xref::functions/list.adoc#functions-coll-distinct[`coll.distinct()`] +| `coll.distinct(list :: LIST) :: LIST` +| Returns the given list with all duplicate values removed. + +1.1+| xref::functions/list.adoc#functions-coll-flatten[`coll.flatten()`] +| `coll.flatten(list :: LIST, depth = 1 :: INTEGER) :: LIST` +| Returns a list flattened to the given depth. + +1.1+| xref::functions/list.adoc#functions-coll-indexOf[`coll.indexOf()`] +| `coll.indexOf(list :: LIST, value :: ANY) :: INTEGER` +| Returns the index for the first match of value in the given list, if the value is no present, -1 is returned. + +1.1+| xref::functions/list.adoc#functions-coll-insert[`coll.insert()`] +| `coll.insert(list :: LIST, index :: INTEGER, value :: ANY) :: LIST` +| Returns a list with the given value inserted at the given index. + +1.1+| xref::functions/list.adoc#functions-coll-max[`coll.max()`] +| `coll.max(list :: LIST) :: ANY` +| Returns the largest value. + +1.1+| xref::functions/list.adoc#functions-coll-min[`coll.min()`] +| `coll.min(list :: LIST) :: ANY` +| Returns the smallest value. + +1.1+| xref::functions/list.adoc#functions-coll-remove[`coll.remove()`] +| `coll.remove(list :: LIST, index :: INTEGER) :: LIST` +| Returns a list with the value at the given index removed. + +1.1+| xref::functions/list.adoc#functions-coll-sort[`coll.sort()`] +| `coll.sort(list :: LIST) :: LIST` +| Returns a sorted list. + 1.1+| xref::functions/list.adoc#functions-keys[`keys()`] | `keys(input :: NODE \| RELATIONSHIP \| MAP) :: LIST` | Returns a `LIST` containing the `STRING` representations for all the property names of a `MAP`, `NODE`, or `RELATIONSHIP`. diff --git a/modules/ROOT/pages/functions/list.adoc b/modules/ROOT/pages/functions/list.adoc index 3d5c59010..952a29ec2 100644 --- a/modules/ROOT/pages/functions/list.adoc +++ b/modules/ROOT/pages/functions/list.adoc @@ -27,7 +27,7 @@ CREATE (alice:Developer {name:'Alice', age: 38, eyes: 'Brown'}), (bob:Administrator {name: 'Bob', age: 25, eyes: 'Blue'}), (charlie:Administrator {name: 'Charlie', age: 53, eyes: 'Green'}), - (daniel:Adminstrator {name: 'Daniel', age: 54, eyes: 'Brown'}), + (daniel:Administrator {name: 'Daniel', age: 54, eyes: 'Brown'}), (eskil:Designer {name: 'Eskil', age: 41, eyes: 'blue', likedColors: ['Pink', 'Yellow', 'Black']}), (alice)-[:KNOWS]->(bob), (alice)-[:KNOWS]->(charlie), @@ -36,6 +36,431 @@ CREATE (bob)-[:MARRIED]->(eskil) ---- +[[functions-coll-distinct]] +== coll.distinct() + +.Details +|=== +| *Syntax* 3+| `coll.distinct(list)` +| *Description* 3+| Returns the given list with all duplicate values removed. +.2+| *Arguments* | *Name* | *Type* | *Description* +| `list` | `LIST` | A list to be deduplicated. +| *Returns* 3+| `LIST` +|=== + +.Considerations +|=== +| `coll.distinct(null)` returns `null`. +| The order of the first occurrences of the distinct values is preserved. +|=== + +.+coll.distinct()+ +====== + +.Deduplicate a list of integer values +// tag::functions_list_distinct_ints[] +[source, cypher] +---- +RETURN coll.distinct([1, 3, 2, 4, 2, 3, 1]) +---- +// end::functions_list_distinct_ints[] + +A `LIST` containing only unique values is returned. + +.Result +[role="queryresult",options="header,footer",cols="1*` containing only unique values is returned. + +.Result +[role="queryresult",options="header,footer",cols="1*` | A nested list to be flattened. +| `depth` | `INTEGER` | The maximum depth to flatten to (default value: 1). +| *Returns* 3+| `LIST` +|=== + +.Considerations +|=== +| Preserves the original order of non-list items. +| If `depth` is 0, the input list is returned unchanged. +| `depth` must be a non-negative integer. +| `coll.flatten(null)` returns `null`. +| `coll.flatten(list, null)` returns `null`. +| `coll.flatten(null, depth)` returns `null`. +| `coll.flatten(null, null)` returns `null`. + +|=== + + +.+coll.flatten()+ +====== + +.Flatten a list containing nesting to level 2 +// tag::functions_list_flatten[] +[source, cypher] +---- +RETURN coll.flatten(['a', ['b', ['c']]], 2) +---- +// end::functions_list_flatten[] + +A `LIST` with any inner lists up to a nesting depth of 2 flattened. + +.Result +[role="queryresult",options="header,footer",cols="1*` with any inner lists up to a nesting depth of 1 (default depth) flattened. + +.Result +[role="queryresult",options="header,footer",cols="1*` | A list to be searched. +| `value` | `ANY` | A value to search for. +| *Returns* 3+| `INTEGER` +|=== + +.Considerations +|=== + +| Indexing is 0-based. +| Returns -1 if the value is not present in the list. +| `coll.indexOf(null, null)` returns `null`. +| `coll.indexOf(null, value)` returns `null`. +| `coll.indexOf(list, null)` returns `null`. + +|=== + + +.+coll.indexOf()+ +====== + +.Find the first index of a given value +// tag::functions_list_indexOf[] +[source, cypher] +---- +RETURN coll.indexOf(['a', 'b', 'c', 'c'], 'c') +---- +// end::functions_list_indexOf[] + +An `INTEGER` representing the index of the item in the list. + +.Result +[role="queryresult",options="header,footer",cols="1*` | A list to add to. +| `index` | `INTEGER` | The index to add the given value at. +| `value` | `ANY` | The value to add into the list. +| *Returns* 3+| `LIST` +|=== + +.Considerations +|=== +| Indexing is 0-based. +| `coll.insert(null, null, value)` returns `null`. +| `coll.insert(list, null, value)` returns `null`. +| `coll.insert(null, 1, value)` returns `null`. +| If the given `index` is negative or larger than the size of the given list, an error is returned. + +|=== + + +.+coll.insert()+ +====== + +.Query +// tag::functions_list_insert[] +[source, cypher] +---- +RETURN coll.insert([true, 'a', 1, 5.4], 1, false) +---- +// end::functions_list_insert[] + +The original list with a new value inserted at the given index, shifting all the values following by 1. + +.Result +[role="queryresult",options="header,footer",cols="1*` | A list to be searched. +| *Returns* 3+| `ANY` +|=== + +.Considerations +|=== +| `coll.max(null)` returns `null`. +| `coll.max([])` returns `null`. +| The maximum is determined using Cypher's standard value ordering; see xref:values-and-types/ordering-equality-comparison.adoc[]. +|=== + + +.+coll.max()+ +====== + +.Query +// tag::functions_list_max[] +[source, cypher] +---- +RETURN coll.max([true, 'a', 1, 5.4]) +---- +// end::functions_list_max[] + +The maximum value found in the given list based on Cypher's ordering. + +.Result +[role="queryresult",options="header,footer",cols="1*` | A list to be searched. +| *Returns* 3+| `ANY` +|=== + +.Considerations +|=== +| `coll.min(null)` returns `null`. +| `coll.min([])` returns `null`. +| The minimum is determined using Cypher's standard value ordering; see xref:values-and-types/ordering-equality-comparison.adoc[]. +|=== + + +.+coll.min()+ +====== + +.Query +// tag::functions_list_min[] +[source, cypher] +---- +RETURN coll.min([true, 'a', 1, 5.4]) +---- +// end::functions_list_min[] + +The minimum value found in the given list based on Cypher's ordering. + +.Result +[role="queryresult",options="header,footer",cols="1*` | A list to remove a value from. +| `index` | `INTEGER` | The index of the value to be removed. +| *Returns* 3+| `LIST` +|=== + +.Considerations +|=== +| Indexing is 0-based. +| `coll.remove(null, null)` returns `null`. +| `coll.remove(null, index)` returns `null`. +| `coll.remove(list, null)` returns `null`. +| If the given `index` is negative or larger than the size of the given list, an error is returned. + +|=== + + +.+coll.remove()+ +====== + +.Query +// tag::functions_list_remove[] +[source, cypher] +---- +RETURN coll.remove([true, 'a', 1, 5.4], 1) +---- +// end::functions_list_remove[] + +The original list with the value at the given index removed and all values following shifted by 1. + +.Result +[role="queryresult",options="header,footer",cols="1*` | A list to be sorted. +| *Returns* 3+| `LIST` +|=== + +.Considerations +|=== +| Sorting follows Cypher's standard value ordering; see xref:values-and-types/ordering-equality-comparison.adoc[]. +| `coll.sort(null)` returns `null`. + +|=== + + +.+coll.sort()+ +====== + +.Query +// tag::functions_list_sort[] +[source, cypher] +---- +RETURN coll.sort([true, 'a', 1, 2]) +---- +// end::functions_list_sort[] + +The list sorted using Cypher's ordering in ascending order. + +.Result +[role="queryresult",options="header,footer",cols="1*