Microsoft Fabric 的 Cosmos DB 数据库工作负荷提供内置的示例数据集,可帮助你探索、学习和试验 NoSQL 数据库模式。 此数据集表示具有产品和客户评审的电子商务方案,演示不同实体类型在同一容器中共存的方式。
有两个示例数据集可用:
- 标准示例数据:具有产品和评论的核心电子商务数据
- 矢量示例数据:增强版本,其中包括使用 OpenAI 的文本嵌入-ada-002 模型生成的 1536 维矢量嵌入,用于语义搜索方案。
数据集概述
这两个示例数据集都包含具有两种文档类型的同一电子商务数据。
-
产品文档 (
docType: "product") - 具有名称、说明、库存、当前价格和该产品价格历史记录的嵌入数组的各个产品。 -
审核文档 (
docType: "review") - 通过productId链接到产品的客户评论和评级productId
矢量示例数据集基于标准示例数据集。 矢量数据集中的产品文档包括一个附加 vectors 属性,其中包含用于语义搜索功能的 1536 维嵌入。
注释
可以在 Cosmos DB 的示例数据集文件夹中找到两个数据集以及一个包含使用 OpenAI text-embedding-3-large 模型生成的512维向量的附加数据集,该文件夹位于 Fabric - Samples Repository 中
文档架构
产品文档架构
产品文档包含有关电子商务目录中各个项目的详细信息:
| 资产 | 类型 | DESCRIPTION |
|---|---|---|
id |
string |
GUID 格式的产品的唯一标识符 |
docType |
string |
文档类型标识符,始终 "product" |
productId |
string |
产品标识符,与 id 产品文档相同 |
name |
string |
产品显示名称 |
description |
string |
详细的产品说明 |
categoryName |
string |
产品类别(例如“计算机、笔记本电脑”、“媒体”、“附件”) |
inventory |
number |
当前库存的项目数 |
firstAvailable |
string |
产品可用日期(ISO 8601 格式) |
currentPrice |
number |
当前销售价格 |
priceHistory |
array |
带有 date 和 price 字段的价格更改对象数组 |
priceHistory[].date |
string |
ISO 8601 格式的价格变化日期和时间 |
priceHistory[].price |
number |
指定日期的价格 |
vectors |
array |
仅矢量示例数据 - 1536 维矢量嵌入 |
查看文档架构
审阅文档包含产品的客户反馈和评级:
| 资产 | 类型 | DESCRIPTION |
|---|---|---|
id |
string |
GUID 格式的评审唯一标识符 |
docType |
string |
文档类型标识符,始终 "review" |
productId |
string |
id引用正在审阅的产品 |
categoryName |
string |
产品类别(继承自评审过的产品) |
customerName |
string |
撰写评论的客户的姓名 |
reviewDate |
string |
提交评审的日期(ISO 8601 格式) |
stars |
number |
客户给出的评级(1-5 范围) |
reviewText |
string |
客户的书面评论内容 |
注释
Cosmos DB 为所有文档自动生成系统属性(_rid、_self、_etag、_attachments_ts)。
示例文档
以下示例显示了两个示例数据集中的文档结构。
标准产品文档示例
{
"id": "ae449848-3f15-4147-8eee-fe76cfcc6bb4",
"docType": "product",
"productId": "ae449848-3f15-4147-8eee-fe76cfcc6bb4",
"name": "EchoSphere Pro ANC-X900 Premium Headphones",
"description": "EchoSphere Pro ANC-X900 Premium Headphones deliver immersive sound with advanced 40mm drivers and Adaptive Hybrid Active Noise Cancellation. Bluetooth 5.3 ensures seamless connectivity.",
"categoryName": "Accessories, Premium Headphones",
"inventory": 772,
"firstAvailable": "2024-01-01T00:00:00",
"currentPrice": 454.87,
"priceHistory": [
{
"date": "2024-01-01T00:00:00",
"price": 349.0
},
{
"date": "2024-08-01T00:00:00",
"price": 363.0
},
{
"date": "2025-04-01T00:00:00",
"price": 408.14
},
{
"date": "2025-08-01T00:00:00",
"price": 454.87
}
]
}
矢量化产品文档示例
{
"id": "ae449848-3f15-4147-8eee-fe76cfcc6bb4",
"docType": "product",
"productId": "ae449848-3f15-4147-8eee-fe76cfcc6bb4",
"name": "EchoSphere Pro ANC-X900 Premium Headphones",
"description": "EchoSphere Pro ANC-X900 Premium Headphones deliver immersive sound with advanced 40mm drivers and Adaptive Hybrid Active Noise Cancellation. Bluetooth 5.3 ensures seamless connectivity.",
"categoryName": "Accessories, Premium Headphones",
"inventory": 772,
"firstAvailable": "2024-01-01T00:00:00",
"currentPrice": 454.87,
"priceHistory": [
{
"date": "2024-01-01T00:00:00",
"price": 349.0
},
{
"date": "2025-08-01T00:00:00",
"price": 454.87
}
],
"vectors": [
-0.02783808670938015,
0.011827611364424229,
-0.04711977392435074,
// ... (1536 dimensions total)
0.04251981899142265
]
}
查看文档示例
审核文件在两个示例数据集中完全相同。
{
"id": "fa799013-1746-4a7f-bd0f-2a95b2b76481",
"docType": "review",
"productId": "e847e069-d0f9-4fec-b42a-d37cd5b2f536",
"categoryName": "Accessories, Premium Headphones",
"customerName": "Emily Rodriguez",
"reviewDate": "2025-03-02T00:00:00",
"stars": 5,
"reviewText": "Excellent sound quality! Premium build! This EchoSphere Pro ANC-X900 exceeded hopes."
}
如何使用示例数据
这两个示例数据集都有助于练习在 Cosmos DB 中查询、筛选和聚合数据。 混合文档类型为各种用例提供现实方案。
标准示例数据场景
-
联接相关数据:使用
productId将评论链接到产品productId -
类别分析:查询产品和评论
categoryName - 评审分析:检查客户反馈模式和评级
常见查询模式
获取类别中的所有产品:
SELECT *
FROM c
WHERE
c.docType = "product" AND
c.categoryName = "Computers, Laptops"
获取特定产品的评论:
SELECT *
FROM c
WHERE
c.docType = "review" AND
c.productId = "77be013f-4036-4311-9b5a-dab0c3d022be"
矢量示例数据场景
- 语义相似性搜索:使用矢量嵌入查找具有类似功能的产品
- 基于内容的建议:根据描述相似性生成产品建议
- 混合查询:将传统筛选器与矢量相似性相结合,以提高结果
JSON 架构
以下 JSON 架构描述了两个示例数据集中的文档结构。 使用这些架构来验证或生成自己的 Cosmos DB 工作负载的类似数据。
标准产品文档架构
{
"type": "object",
"properties": {
"id": { "type": "string" },
"docType": { "type": "string" },
"productId": { "type": "string" },
"name": { "type": "string" },
"description": { "type": "string" },
"categoryName": { "type": "string" },
"inventory": { "type": "number" },
"firstAvailable": { "type": "string" },
"currentPrice": { "type": "number" },
"priceHistory": {
"type": "array",
"items": {
"type": "object",
"properties": {
"date": { "type": "string" },
"price": { "type": "number" }
},
"required": ["date", "price"]
}
}
},
"required": [
"id", "docType", "productId", "name", "description", "categoryName", "inventory", "firstAvailable", "currentPrice", "priceHistory"
]
}
支持矢量的产品文档架构
{
"type": "object",
"properties": {
"id": { "type": "string" },
"docType": { "type": "string" },
"productId": { "type": "string" },
"name": { "type": "string" },
"description": { "type": "string" },
"categoryName": { "type": "string" },
"inventory": { "type": "number" },
"firstAvailable": { "type": "string" },
"currentPrice": { "type": "number" },
"priceHistory": {
"type": "array",
"items": {
"type": "object",
"properties": {
"date": { "type": "string" },
"price": { "type": "number" }
},
"required": ["date", "price"]
}
},
"vectors": {
"type": "array",
"items": { "type": "number" },
"minItems": 1536,
"maxItems": 1536
}
},
"required": [
"id", "docType", "productId", "name", "description", "categoryName", "inventory", "firstAvailable", "currentPrice", "priceHistory", "vectors"
]
}
查看文档架构
{
"type": "object",
"properties": {
"id": { "type": "string" },
"docType": { "type": "string", "const": "review" },
"productId": { "type": "string" },
"categoryName": { "type": "string" },
"customerName": { "type": "string" },
"reviewDate": { "type": "string" },
"stars": { "type": "number" },
"reviewText": { "type": "string" }
},
"required": [
"id", "docType", "productId", "categoryName", "customerName",
"reviewDate", "stars"
]
}