Skip to content

Commit bc96e3f

Browse files
authored
Update date and enhance example explanations
1 parent aec96c5 commit bc96e3f

File tree

1 file changed

+44
-40
lines changed

1 file changed

+44
-40
lines changed

articles/cosmos-db/mongodb/vcore/operators/set-expression/$setintersection.md

Lines changed: 44 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
ms.service: azure-cosmos-db
88
ms.subservice: mongodb-vcore
99
ms.topic: language-reference
10-
ms.date: 08/03/2025
10+
ms.date: 09/04/2025
1111
---
1212

1313
# $setIntersection
@@ -28,9 +28,9 @@ The `$setIntersection` operator returns an array that contains elements that app
2828
| --- | --- |
2929
| `<array1>, <array2>, ...` | Two or more arrays to find the intersection of. Each array is treated as a set. |
3030

31-
## Example
31+
## Examples
3232

33-
Let's understand the usage with sample JSON from the `stores` dataset.
33+
Consider this sample document from the stores collection.
3434

3535
```json
3636
{
@@ -160,7 +160,7 @@ Let's understand the usage with sample JSON from the `stores` dataset.
160160

161161
### Example 1: Find common categories between sales and promotions
162162

163-
The following example helps you determine which product categories appear in a store's sales data and promotion discounts.
163+
This query determines which product categories appear in a store's sales data and promotion discounts.
164164

165165
```javascript
166166
db.stores.aggregate([
@@ -188,42 +188,44 @@ db.stores.aggregate([
188188
])
189189
```
190190

191-
The query output shows which categories are common between sales and promotion events.
191+
This query returns the following result.
192192

193193
```json
194-
{
195-
"_id": "40d6f4d7-50cd-4929-9a07-0a7a133c2e74",
196-
"name": "Proseware, Inc. | Home Entertainment Hub - East Linwoodbury",
197-
"salesCategories": [
198-
"Sound Bars",
199-
"Game Controllers",
200-
"Remote Controls",
201-
"VR Games"
202-
],
203-
"firstPromotionCategories": [
204-
"DVD Players",
205-
"Projector Lamps",
206-
"Media Players",
207-
"Blu-ray Players",
208-
"Home Theater Systems",
209-
"Televisions"
210-
],
211-
"secondPromotionCategories": [
212-
"TV Mounts",
213-
"Game Accessories",
214-
"Portable Projectors",
215-
"Projector Screens",
216-
"Blu-ray Players",
217-
"DVD Players"
218-
],
219-
"commonSalesAndFirstPromotion": [],
220-
"commonSalesAndSecondPromotion": []
221-
}
194+
[
195+
{
196+
"_id": "40d6f4d7-50cd-4929-9a07-0a7a133c2e74",
197+
"name": "Proseware, Inc. | Home Entertainment Hub - East Linwoodbury",
198+
"salesCategories": [
199+
"Sound Bars",
200+
"Game Controllers",
201+
"Remote Controls",
202+
"VR Games"
203+
],
204+
"firstPromotionCategories": [
205+
"DVD Players",
206+
"Projector Lamps",
207+
"Media Players",
208+
"Blu-ray Players",
209+
"Home Theater Systems",
210+
"Televisions"
211+
],
212+
"secondPromotionCategories": [
213+
"TV Mounts",
214+
"Game Accessories",
215+
"Portable Projectors",
216+
"Projector Screens",
217+
"Blu-ray Players",
218+
"DVD Players"
219+
],
220+
"commonSalesAndFirstPromotion": [],
221+
"commonSalesAndSecondPromotion": []
222+
}
223+
]
222224
```
223225

224226
### Example 2: Find common categories across multiple promotion events
225227

226-
The following example helps you find categories that appear in multiple promotion events.
228+
This query fetches categories that appear in multiple promotion events.
227229

228230
```javascript
229231
db.stores.aggregate([
@@ -243,14 +245,16 @@ db.stores.aggregate([
243245
])
244246
```
245247

246-
The query returns an empty array for `commonAcrossPromotions`, because there are no common product categories that appear across all of the promotions.
248+
This query returns the following result.
247249

248250
```json
249-
{
250-
"_id": "40d6f4d7-50cd-4929-9a07-0a7a133c2e74",
251-
"name": "Proseware, Inc. | Home Entertainment Hub - East Linwoodbury",
252-
"commonAcrossPromotions": []
253-
}
251+
[
252+
{
253+
"_id": "40d6f4d7-50cd-4929-9a07-0a7a133c2e74",
254+
"name": "Proseware, Inc. | Home Entertainment Hub - East Linwoodbury",
255+
"commonAcrossPromotions": []
256+
}
257+
]
254258
```
255259

256260
## Related content

0 commit comments

Comments
 (0)