创建向量桶
Set up vector buckets and indexes using the dashboard or JavaScript SDK.
此功能处于测试阶段
预计会有快速变化、功能有限,并可能出现破坏性更新。随着我们改进体验并扩大访问,欢迎分享反馈。
🌐 Expect rapid changes, limited features, and possible breaking updates. Share feedback as we refine the experience and expand access.
向量桶将你的向量数据组织成逻辑单元。在每个桶里,你可以创建索引,定义向量如何根据它们的维度和距离度量来存储和搜索。
🌐 Vector buckets organize your vector data into logical units. Within each bucket, you create indexes that define how vectors are stored and searched based on their dimensions and distance metrics.
创建一个向量桶 #
🌐 Creating a Vector bucket
你可以使用 Supabase 仪表板或 SDK 来创建向量桶。
🌐 You can create vector buckets using either the Supabase Dashboard or the SDK.
使用 Supabase 控制台 #
🌐 Using the Supabase Dashboard
- 在 Supabase 仪表板中导航到 存储 部分。
- 点击 创建存储桶。
- 为你的存储桶输入一个名称(例如,
embeddings或semantic-search)。 - 选择 向量桶 作为桶类型。
- 点击创建。
你的向量桶现在已经准备好了。下一步是创建索引。
🌐 Your vector bucket is now ready. The next step is to create indexes within it.
使用 SDK #
🌐 Using the SDK
1import { createClient } from '@supabase/supabase-js'23const supabase = createClient('https://your-project-id.supabase.co', 'your-service-key')45// Create a vector bucket6await supabase.storage.vectors.createBucket('embeddings')78console.log('✓ Vector bucket created: embeddings')创建索引 #
🌐 Creating indexes
索引可以在具有一致维度和距离度量的桶中组织向量。有关全面的索引管理文档,请参阅 使用向量索引。
🌐 Indexes organize vectors within a bucket with consistent dimensions and distance metrics. For comprehensive index management documentation, see Working with Vector Indexes.
快速入门:通过仪表板创建索引 #
🌐 Quick start: Creating an index via Dashboard
- 打开你的矢量桶。
- 点击 创建索引。
- 输入一个索引名称(例如,
documents-openai)。 - 设置与你的嵌入向量匹配的维度(例如,对于 OpenAI 的 text-embedding-3-small,使用
1536)。 - 选择距离度量(
cosine、euclidean或l2)。 - 点击创建。
快速入门:通过 SDK 创建索引 #
🌐 Quick start: Creating an index via SDK
1const bucket = supabase.storage.vectors.from('embeddings')23// Create an index4await bucket.createIndex({5 indexName: 'documents-openai',6 dataType: 'float32',7 dimension: 1536,8 distanceMetric: 'cosine',9})1011console.log('✓ Index created: documents-openai')关键细节 #
🌐 Key details
- 维度 必须与你的嵌入模型匹配(例如,OpenAI 为 1536)
- 距离度量(
cosine、euclidean或l2)在创建后不可更改 - 每个桶的最大索引数:10
- 最大批量大小:每次操作 500 个向量
有关距离度量、嵌入维度、管理多个索引以及高级索引操作的详细信息,请参见 使用向量索引。
🌐 For detailed information on distance metrics, embedding dimensions, managing multiple indexes, and advanced index operations, see Working with Vector Indexes.
下一步 #
🌐 Next steps
在创建你的存储桶和索引后,你可以:
🌐 After creating your bucket and indexes, you can: