Skip to content

Commit 9fce033

Browse files
author
Jill Grant
authored
Merge pull request #283731 from seesharprun/cosmos-new-nosql-query-functions
Cosmos DB | New NoSQL query functions
2 parents 99c1502 + 41124d3 commit 9fce033

File tree

10 files changed

+406
-44
lines changed

10 files changed

+406
-44
lines changed

articles/cosmos-db/nosql/query/TOC.yml

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@
6565
- name: Bitwise operators
6666
displayName: bitwise, binary, operators
6767
href: bitwise-operators.md
68+
- name: Vector functions
69+
items:
70+
- name: VectorDistance
71+
displayName: vector, distance, AI
72+
href: vectordistance.md
6873
- name: Aggregate functions
6974
items:
7075
- name: AVG
@@ -73,10 +78,10 @@
7378
- name: COUNT
7479
displayName: functions, aggregate, count
7580
href: count.md
76-
- name: MAX
81+
- name: Maximum
7782
displayName: functions, aggregate, max, maximum
7883
href: max.md
79-
- name: MIN
84+
- name: Minimum
8085
displayName: functions, aggregate, min, minimum
8186
href: min.md
8287
- name: SUM
@@ -90,16 +95,22 @@
9095
- name: Array functions
9196
items:
9297
- name: ARRAY_CONCAT
93-
displayName: ARRAY_CONCAT, array concat, array functions
98+
displayName: ARRAY_CONCAT, concat, array concat, array functions
9499
href: array-concat.md
95100
- name: ARRAY_CONTAINS
96-
displayName: ARRAY_CONTAINS, array contains, array functions
101+
displayName: ARRAY_CONTAINS, contains, array contains, array functions
97102
href: array-contains.md
103+
- name: ARRAY_CONTAINS_ANY
104+
displayName: ARRAY_CONTAINS_ANY, contains, array contains, array contains any, any, array functions
105+
href: array-contains-any.md
106+
- name: ARRAY_CONTAINS_ALL
107+
displayName: ARRAY_CONTAINS_ALL, contains, array contains, array contains all, all, array functions
108+
href: array-contains-all.md
98109
- name: ARRAY_LENGTH
99-
displayName: ARRAY_LENGTH, array length, array functions
110+
displayName: ARRAY_LENGTH, length, array length, array functions
100111
href: array-length.md
101112
- name: ARRAY_SLICE
102-
displayName: ARRAY_SLICE, array slice, array functions
113+
displayName: ARRAY_SLICE, slice, array slice, array functions
103114
href: array-slice.md
104115
- name: CHOOSE
105116
displayName: CHOOSE, choose, choose index, select item, array functions
@@ -115,7 +126,7 @@
115126
href: setunion.md
116127
- name: Conditional functions
117128
items:
118-
- name: IIF
129+
- name: Ternary conditional
119130
displayName: IIF, ternary, ternary conditional operator
120131
href: iif.md
121132
- name: Date and time functions
@@ -365,6 +376,12 @@
365376
- name: StringToObject
366377
displayName: StringToObject, string to object, built-in functions
367378
href: stringtoobject.md
379+
- name: StringJoin
380+
displayName: StringJoin, string join, built-in functions
381+
href: stringjoin.md
382+
- name: StringSplit
383+
displayName: StringSplit, string split, built-in functions
384+
href: stringsplit.md
368385
- name: SUBSTRING
369386
displayName: SUBSTRING, built-in functions
370387
href: substring.md
@@ -421,6 +438,6 @@
421438
- name: Pagination
422439
displayName: continuation tokens, paging, pagination
423440
href: pagination.md
424-
- name: LINQ to NoSQL
441+
- name: Linq to NoSQL
425442
displayName: linq, .NET
426443
href: linq-to-sql.md
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
---
2+
title: ARRAY_CONTAINS_ALL
3+
titleSuffix: Azure Cosmos DB for NoSQL
4+
description: An Azure Cosmos DB for NoSQL system function that returns a boolean indicating whether the array contains all of the specified values.
5+
author: seesharprun
6+
ms.author: sidandrews
7+
ms.reviewer: jacodel
8+
ms.service: azure-cosmos-db
9+
ms.subservice: nosql
10+
ms.topic: reference
11+
ms.devlang: nosql
12+
ms.date: 08/06/2024
13+
ms.custom: query-reference
14+
---
15+
16+
# ARRAY_CONTAINS_ALL (NoSQL query)
17+
18+
[!INCLUDE[NoSQL](../../includes/appliesto-nosql.md)]
19+
20+
Returns a boolean value indicates if the first array contains all the following elements.
21+
22+
## Syntax
23+
24+
```nosql
25+
ARRAY_CONTAINS_ALL(<array_expr>, <expr> [, exprN])
26+
```
27+
28+
## Arguments
29+
30+
| | Description |
31+
| --- | --- |
32+
| **`array_expr`** | An array expression. |
33+
| **`expr`** | Expression to search for within the array. |
34+
| **`exprN`** (Optional) | One or more extra expressions to to search for within the array. |
35+
36+
## Return types
37+
38+
Returns a boolean value.
39+
40+
## Examples
41+
42+
The following example illustrates how to check for specific values or objects in an array using this function.
43+
44+
```nosql
45+
SELECT VALUE {
46+
matchesEntireArray: ARRAY_CONTAINS_ALL([1, true, "3", [1,2,3]], 1, true, "3", [1,2,3]),
47+
matchesSomeValues: ARRAY_CONTAINS_ALL([1, 2, 3, 4], 2, 3, 4, 5),
48+
matchSingleValue: ARRAY_CONTAINS_ALL([1, 2, 3, 4], 1, undefined),
49+
noMatches: ARRAY_CONTAINS_ALL([1, 2, 3, 4], 5, 6, 7, 8),
50+
emptyArray: ARRAY_CONTAINS_ALL([], 1, 2, 3),
51+
noMatchesUndefined: ARRAY_CONTAINS_ALL([1, 2, 3, 4], 5, undefined)
52+
}
53+
```
54+
55+
```json
56+
[
57+
{
58+
"matchesEntireArray": true,
59+
"matchesSomeValues": false,
60+
"noMatches": false,
61+
"emptyArray": false,
62+
"noMatchesUndefined": false
63+
}
64+
]
65+
```
66+
67+
## Remarks
68+
69+
- This system function doesn't utilize the index.
70+
71+
## Related content
72+
73+
- [`ARRAY_CONTAINS`](array-contains.md)
74+
- [`ARRAY_CONTAINS_ANY`](array-contains-any.md)
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
---
2+
title: ARRAY_CONTAINS_ANY
3+
titleSuffix: Azure Cosmos DB for NoSQL
4+
description: An Azure Cosmos DB for NoSQL system function that returns a boolean indicating whether the array contains any of the specified values.
5+
author: seesharprun
6+
ms.author: sidandrews
7+
ms.reviewer: jacodel
8+
ms.service: azure-cosmos-db
9+
ms.subservice: nosql
10+
ms.topic: reference
11+
ms.devlang: nosql
12+
ms.date: 08/06/2024
13+
ms.custom: query-reference
14+
---
15+
16+
# ARRAY_CONTAINS_ANY (NoSQL query)
17+
18+
[!INCLUDE[NoSQL](../../includes/appliesto-nosql.md)]
19+
20+
Returns a boolean value indicates if the first array contains any of the following elements.
21+
22+
## Syntax
23+
24+
```nosql
25+
ARRAY_CONTAINS_ANY(<array_expr>, <expr> [, exprN])
26+
```
27+
28+
## Arguments
29+
30+
| | Description |
31+
| --- | --- |
32+
| **`array_expr`** | An array expression. |
33+
| **`expr`** | Expression to search for within the array. |
34+
| **`exprN`** (Optional) | One or more extra expressions to to search for within the array. |
35+
36+
## Return types
37+
38+
Returns a boolean value.
39+
40+
## Examples
41+
42+
The following example illustrates how to check for specific values or objects in an array using this function.
43+
44+
```nosql
45+
SELECT VALUE {
46+
matchesEntireArray: ARRAY_CONTAINS_ANY([1, true, "3", [1,2,3]], 1, true, "3", [1,2,3]),
47+
matchesSomeValues: ARRAY_CONTAINS_ANY([1, 2, 3, 4], 2, 3, 4, 5),
48+
matchSingleValue: ARRAY_CONTAINS_ANY([1, 2, 3, 4], 1, undefined),
49+
noMatches: ARRAY_CONTAINS_ANY([1, 2, 3, 4], 5, 6, 7, 8),
50+
emptyArray: ARRAY_CONTAINS_ANY([], 1, 2, 3),
51+
noMatchesUndefined: ARRAY_CONTAINS_ANY([1, 2, 3, 4], 5, undefined)
52+
}
53+
```
54+
55+
```json
56+
[
57+
{
58+
"matchesEntireArray": true,
59+
"matchesSomeValues": true,
60+
"matchSingleValue": true,
61+
"noMatches": false,
62+
"emptyArray": false
63+
}
64+
]
65+
```
66+
67+
## Remarks
68+
69+
- This system function doesn't utilize the index.
70+
71+
## Related content
72+
73+
- [`ARRAY_CONTAINS`](array-contains.md)
74+
- [`ARRAY_CONTAINS_ALL`](array-contains-all.md)

articles/cosmos-db/nosql/query/array-contains.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: ARRAY_CONTAINS
33
titleSuffix: Azure Cosmos DB for NoSQL
4-
description: An Azure Cosmos DB for NoSQL system function that returns a boolean indicating whether the array contains the specified value
4+
description: An Azure Cosmos DB for NoSQL system function that returns a boolean indicating whether the array contains the specified value.
55
author: jcodella
66
ms.author: jacodel
77
ms.reviewer: sidandrews
@@ -26,13 +26,13 @@ ARRAY_CONTAINS(<array_expr>, <expr> [, <bool_expr>])
2626
```
2727

2828
## Arguments
29-
29+
3030
| | Description |
3131
| --- | --- |
3232
| **`arr_expr`** | An array expression. |
3333
| **`expr`** | Expression to search for within the array. |
3434
| **`bool_expr`** | A boolean expression indicating whether the search should check for a partial match (`true`) or a full match (`false`). If not specified, the default value is `false`. |
35-
35+
3636
## Return types
3737

3838
Returns a boolean value.

articles/cosmos-db/nosql/query/index.yml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
### YamlMime:Landing
22

33
title: Queries in Azure Cosmos DB for NoSQL
4-
summary: Azure Cosmos DB for NoSQL provides the ability to query data by writing queries using the Structured Query Language (SQL) as a JSON query language.
4+
summary: Azure Cosmos DB for NoSQL has the ability to query data by writing queries using the Structured Query Language (SQL) as a JSON query language.
55

66
metadata:
77
title: NoSQL queries
88
titleSuffix: Azure Cosmos DB for NoSQL
9-
description: Azure Cosmos DB for NoSQL provides the ability to query data by writing queries using the Structured Query Language (SQL) as a JSON query language.
9+
description: Azure Cosmos DB for NoSQL has the ability to query data by writing queries using the Structured Query Language (SQL) as a JSON query language.
1010
author: jcodella
1111
ms.author: jacodel
1212
ms.reviewer: sidandrews
@@ -30,6 +30,12 @@ landingContent:
3030
url: keywords.md
3131
- text: Constants
3232
url: constants.md
33+
- title: Vector functions
34+
linkLists:
35+
- linkListType: reference
36+
links:
37+
- text: VectorDistance
38+
url: vectordistance.md
3339
- title: Aggregate functions
3440
linkLists:
3541
- linkListType: reference
@@ -38,9 +44,9 @@ landingContent:
3844
url: average.md
3945
- text: COUNT
4046
url: count.md
41-
- text: MAX
47+
- text: Maximum
4248
url: max.md
43-
- text: MIN
49+
- text: Minimum
4450
url: min.md
4551
- text: SUM
4652
url: sum.md
@@ -52,6 +58,10 @@ landingContent:
5258
url: array-concat.md
5359
- text: ARRAY_CONTAINS
5460
url: array-contains.md
61+
- text: ARRAY_CONTAINS_ANY
62+
url: array-contains-any.md
63+
- text: ARRAY_CONTAINS_ALL
64+
url: array-contains-all.md
5565
- text: ARRAY_LENGTH
5666
url: array-length.md
5767
- text: ARRAY_SLICE
@@ -65,7 +75,7 @@ landingContent:
6575
- text: GetCurrentTicks
6676
url: getcurrentticks.md
6777
- text: GetCurrentTimestamp
68-
url: getcurrenttimestamp.md
78+
url: getcurrenttimestamp.md
6979
- title: Mathematical functions
7080
linkLists:
7181
- linkListType: reference
@@ -75,4 +85,4 @@ landingContent:
7585
- text: EXP
7686
url: exp.md
7787
- text: SIN
78-
url: sin.md
88+
url: sin.md

articles/cosmos-db/nosql/query/stringequals.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ms.service: azure-cosmos-db
99
ms.subservice: nosql
1010
ms.topic: reference
1111
ms.devlang: nosql
12-
ms.date: 02/27/2024
12+
ms.date: 08/06/2024
1313
ms.custom: query-reference
1414
---
1515

@@ -22,7 +22,7 @@ Returns a boolean indicating whether the first string expression matches the sec
2222
## Syntax
2323

2424
```nosql
25-
STRINGEQUALS(<string_expr_1>, <string_expr_2> [, <boolean_expr>])
25+
StringEquals(<string_expr_1>, <string_expr_2> [, <boolean_expr>])
2626
```
2727

2828
## Arguments
@@ -39,7 +39,7 @@ Returns a boolean expression.
3939

4040
## Examples
4141

42-
The following example checks if "abc" matches "abc" and if "abc" matches "ABC."
42+
The following example checks if `abc` matches `abc` and if `abc` matches `ABC`.
4343

4444
:::code language="nosql" source="~/cosmos-db-nosql-query-samples/scripts/stringequals/query.sql" highlight="2-4":::
4545

0 commit comments

Comments
 (0)