C#
C# 客户端 (SDK)
最新的 C# 客户端版本是 v1.0.0。
此页面大致涵盖 Weaviate C#(beta 版本)。有关不特定于 C# 客户端的使用信息,例如代码示例,请参阅 操作手册和指南 中的相关页面。
安装
dotnet add package Weaviate.Client --version 1.0.0
要求:Weaviate 版本兼容性 & gRPC
入门
先决条件
如果您尚未这样做,我们建议您首先完成 快速入门教程,以便充分利用本节。
使用此 C# 示例开始使用 Weaviate。代码将引导您完成以下关键步骤
- 连接到 Weaviate:建立到本地(或 Cloud)Weaviate 实例的连接。
- 创建集合:定义
Question集合的数据模式,使用 Ollama 模型对数据进行向量化。 - 导入数据:获取示例 Jeopardy 问题,并使用 Weaviate 的批量导入进行高效摄取和自动向量嵌入生成。
- 搜索/查询数据库:执行向量搜索,以查找与查询
biology语义相似的问题。
// Best practice: store your credentials in environment variables
string weaviateUrl = Environment.GetEnvironmentVariable("WEAVIATE_URL");
string weaviateApiKey = Environment.GetEnvironmentVariable("WEAVIATE_API_KEY");
// 1. Connect to Weaviate Cloud
var client = await Connect.Cloud(weaviateUrl, weaviateApiKey);
// 2. Prepare data
var dataObjects = new List<object>
{
new
{
title = "The Matrix",
description = "A computer hacker learns about the true nature of reality and his role in the war against its controllers.",
genre = "Science Fiction",
},
new
{
title = "Spirited Away",
description = "A young girl becomes trapped in a mysterious world of spirits and must find a way to save her parents and return home.",
genre = "Animation",
},
new
{
title = "The Lord of the Rings: The Fellowship of the Ring",
description = "A meek Hobbit and his companions set out on a perilous journey to destroy a powerful ring and save Middle-earth.",
genre = "Fantasy",
},
};
var CollectionName = "Movie";
await client.Collections.Delete(CollectionName);
// 3. Create the collection
var movies = await client.Collections.Create(
new CollectionCreateParams
{
Name = CollectionName,
VectorConfig = Configure.Vector("default", v => v.Text2VecWeaviate()),
}
);
// 4. Import the data
var result = await movies.Data.InsertMany(dataObjects);
// 5. Run the query
var response = await movies.Query.NearText("sci-fi", limit: 2);
// 6. Inspect the results
foreach (var obj in response.Objects)
{
Console.WriteLine(JsonSerializer.Serialize(obj.Properties));
}
有关更多代码示例,请查看 操作手册和指南 部分。
发布版本
转到 GitHub 发布页面,以查看 C# 客户端库发布历史记录和变更日志。
点击此处查看 Weaviate 和相应客户端版本的表格
此表列出了最新的五个 Weaviate 数据库版本和相应的客户端库版本。
| Weaviate 数据库 (GitHub) | 首次 发布日期 | Python (GitHub) | TypeScript/ JavaScript (GitHub) | Go (GitHub) | Java (GitHub) |
|---|---|---|---|---|---|
| 1.35.x | 2025-12-17 | 4.19.x | N/A | N/A | N/A |
| 1.34.x | 2025-11-05 | 4.18.x | 3.10.x | 5.6.x | 6.0.0 |
| 1.33.x | 2025-09-25 | 4.17.x | 3.9.x | 5.5.x | 5.5.x |
| 1.32.x | 2025-07-14 | 4.16.x | 3.8.x | 5.3.x | 5.4.x |
| 1.31.x | 2025-05-30 | 4.15.x | 3.6.x | 5.2.x | 5.3.x |
| 1.30.x | 2025-04-03 | 4.12.x | 3.5.x | 5.1.x | 5.2.x |
| 1.29.x | 2025-02-17 | 4.11.x | 3.4.x | 5.0.x | 5.1.x |
旧版本发布
| Weaviate 数据库 (GitHub) | 首次 发布日期 | Python (GitHub) | TypeScript/ JavaScript (GitHub) | Go (GitHub) | Java (GitHub) |
|---|---|---|---|---|---|
| 1.28.x | 2024-12-11 | 4.10.x | 3.3.x | 4.16.x | 5.0.x |
| 1.27.x | 2024-10-16 | 4.9.x | 3.2.x | 4.16.x | 5.0.x 4.9.x |
| 1.26.x | 2024-07-22 | 4.7.x | 3.1.x | 4.15.x | 4.8.x |
| 1.25.x | 2024-05-10 | 4.6.x | 2.1.x | 4.13.x | 4.6.x |
| 1.24.x | 2024-02-27 | 4.5.x | 2.0.x | 4.10.x | 4.4.x |
| 1.23.x | 2023-12-18 | 3.26.x | 1.5.x | 4.10.x | 4.4.x |
| 1.22.x | 2023-10-27 | 3.25.x | 1.5.x | 4.10.x | 4.3.x |
| 1.21.x | 2023-08-17 | 3.22.x | 1.4.x | 4.9.x | 4.2.x |
| 1.20.x | 2023-07-06 | 3.22.x | 1.1.x | 4.7.x | 4.2.x |
| 1.19.x | 2023-05-04 | 3.17.x | 1.1.x1 | 4.7.x | 4.0.x |
| 1.18.x | 2023-03-07 | 3.13.x | 2.14.x | 4.6.x | 3.6.x |
| 1.17.x | 2022-12-20 | 3.9.x | 2.14.x | 4.5.x | 3.5.x |
| 1.16.x | 2022-10-31 | 3.8.x | 2.13.x | 4.4.x | 3.4.x |
| 1.15.x | 2022-09-07 | 3.6.x | 2.12.x | 4.3.x | 3.3.x |
| 1.14.x | 2022-07-07 | 3.6.x | 2.11.x | 4.2.x | 3.2.x |
| 1.13.x | 2022-05-03 | 3.4.x | 2.9.x | 4.0.x | 2.4.x |
| 1.12.x | 2022-04-05 | 3.4.x | 2.8.x | 3.0.x | 2.3.x |
| 1.11.x | 2022-03-14 | 3.2.x | 2.7.x | 2.6.x | 2.3.x |
| 1.10.x | 2022-01-27 | 3.1.x | 2.5.x | 2.4.x | 2.1.x |
| 1.9.x | 2021-12-10 | 3.1.x | 2.4.x | 2.4.x | 2.1.x |
| 1.8.x | 2021-11-30 | 3.1.x | 2.4.x | 2.3.x | 1.1.x |
| 1.7.x | 2021-09-01 | 3.1.x | 2.4.x | 2.3.x | 1.1.x |
| 1.6.x | 2021-08-11 | 2.4.x | 2.3.x | 2.2.x | 1.0.x |
| 1.5.x | 2021-07-13 | 2.2.x | 2.1.x | 2.1.x | 1.0.x |
| 1.4.x | 2021-06-09 | 2.2.x | 2.1.x | 2.1.x | 1.0.x |
| 1.3.x | 2021-04-23 | 2.2.x | 2.1.x | 2.1.x | 1.0.x |
| 1.2.x | 2021-03-15 | 2.2.x | 2.0.x | 1.1.x | - |
| 1.1.x | 2021-02-10 | 2.1.x | - | - | - |
| 1.0.x | 2021-01-14 | 2.0.x | - | - | - |
TypeScript 客户端变更
TypeScript 客户端 于 2023-03-17 替换了 JavaScript 客户端。
代码示例和更多资源
可以在 Weaviate 文档中找到有关各种操作和功能的用法信息。
操作指南:配置 Weaviate
配置压缩、备份、身份验证、授权、数据复制等。
操作指南:管理集合
管理集合(CRUD),配置向量化器和索引参数,设置多租户,并执行迁移。
操作指南:管理对象
添加新对象、获取现有对象、修改对象以及从集合中删除对象。
操作指南:查询和搜索
从基本的向量和混合搜索到专门的图像查询以及执行数据聚合。
Weaviate API 参考页面中的 搜索 和 REST 也可能是很好的起点。
问题和反馈
如果您有任何问题或反馈,请在 用户论坛 中告诉我们。
