title | titleSuffix | description | author | ms.author | ms.reviewer | ms.service | ms.subservice | ms.topic | ms.devlang | ms.date | ms.custom |
---|---|---|---|---|---|---|---|---|---|---|---|
ARRAY_SLICE |
Azure Cosmos DB for NoSQL |
An Azure Cosmos DB for NoSQL system function that returns a subset of the items in an array. |
jcodella |
jacodel |
sidandrews |
cosmos-db |
nosql |
reference |
nosql |
02/27/2024 |
query-reference |
[!INCLUDENoSQL]
Returns a subset of an array expression using the index and length specified.
ARRAY_SLICE(<array_expr>, <numeric_expr_1> [, <numeric_expr_2>])
Description | |
---|---|
array_expr |
An array expression. |
numeric_expr_1 |
A numeric expression indicating the index where to begin the array for the subset. Optionally, negative values can be used to specify the starting index relative to the last element of the array. |
numeric_expr_2 (Optional) |
An optional numeric expression indicating the maximum length of elements in the resulting array. |
Returns an array expression.
The following example shows how to get different slices of an array using the function.
:::code language="nosql" source="~/cosmos-db-nosql-query-samples/scripts/array-slice/query.sql" highlight="2-9":::
:::code language="json" source="~/cosmos-db-nosql-query-samples/scripts/array-slice/result.json":::
- This system function doesn't use the index.