From 42c77e8e2bfa50f7004ee33a6ab2710656336edf Mon Sep 17 00:00:00 2001
From: Ivan Despot <66276597+g-despot@users.noreply.github.com>
Date: Tue, 29 Jul 2025 09:04:07 +0200
Subject: [PATCH 01/18] Add C# docs
---
_includes/code/csharp/CollectionTests.cs | 109 ++++++++++++++++++
_includes/code/csharp/ConnectionTests.cs | 27 +++++
_includes/code/csharp/ObjectTests.cs | 53 +++++++++
_includes/code/csharp/SearchTests.cs | 24 ++++
.../code/csharp/WeaviateProject.Tests.csproj | 15 +++
_includes/schema-delete-class.mdx | 9 ++
docs.sln | 32 +++++
docs/weaviate/connections/connect-local.mdx | 9 ++
.../collection-operations.mdx | 17 +++
.../manage-collections/vector-config.mdx | 9 ++
docs/weaviate/manage-objects/create.mdx | 9 ++
docs/weaviate/manage-objects/delete.mdx | 9 ++
docusaurus.config.js | 2 +-
13 files changed, 323 insertions(+), 1 deletion(-)
create mode 100644 _includes/code/csharp/CollectionTests.cs
create mode 100644 _includes/code/csharp/ConnectionTests.cs
create mode 100644 _includes/code/csharp/ObjectTests.cs
create mode 100644 _includes/code/csharp/SearchTests.cs
create mode 100644 _includes/code/csharp/WeaviateProject.Tests.csproj
create mode 100644 docs.sln
diff --git a/_includes/code/csharp/CollectionTests.cs b/_includes/code/csharp/CollectionTests.cs
new file mode 100644
index 000000000..0934dbd15
--- /dev/null
+++ b/_includes/code/csharp/CollectionTests.cs
@@ -0,0 +1,109 @@
+using Xunit;
+using Weaviate.Client;
+using System;
+using System.Threading.Tasks;
+using Weaviate.Client.Models;
+
+namespace WeaviateProject.Tests;
+
+public class CollectionTest
+{
+ [Fact]
+ public async Task Should_Create_Collection()
+ {
+ var client = Connect.Local(restPort: 8085, grpcPort: 50055);
+ // START BasicCreateCollection
+ var collectionName = "Article";
+ // END BasicCreateCollection
+ // Clean up previous runs by deleting the collection if it exists
+ if (await client.Collections.Exists(collectionName))
+ {
+ await client.Collections.Delete(collectionName);
+ Console.WriteLine($"Deleted existing collection: '{collectionName}'");
+ }
+
+ // START BasicCreateCollection
+ var articleCollection = new Collection
+ {
+ Name = collectionName,
+ Description = "Collection description",
+ };
+
+ var collection = await client.Collections.Create(articleCollection);
+ // END BasicCreateCollection
+ Console.WriteLine($"Successfully created collection: '{collectionName}'");
+ }
+
+ [Fact]
+ public async Task Should_Create_Collection_With_Properties()
+ {
+ var client = Connect.Local(restPort: 8085, grpcPort: 50055);
+ // START CreateCollectionWithProperties
+ var collectionName = "Article";
+ // END CreateCollectionWithProperties
+ // Clean up previous runs by deleting the collection if it exists
+ if (await client.Collections.Exists(collectionName))
+ {
+ await client.Collections.Delete(collectionName);
+ Console.WriteLine($"Deleted existing collection: '{collectionName}'");
+ }
+
+ // START CreateCollectionWithProperties
+ var articleCollection = new Collection
+ {
+ Name = collectionName,
+ Description = "something",
+ Properties = [Property.Int("number_property"),Property.Text("test_property")],
+ };
+
+ var collection = await client.Collections.Create(articleCollection);
+ // END CreateCollectionWithProperties
+ Console.WriteLine($"Successfully created collection: '{collectionName}'");
+ }
+
+ [Fact]
+ public async Task Should_Create_Collection_With_Vectorizer()
+ {
+ var client = Connect.Local(restPort: 8085, grpcPort: 50055);
+ // START CreateCollectionWithVectorizer
+ var collectionName = "Article";
+ // END CreateCollectionWithVectorizer
+ // Clean up previous runs by deleting the collection if it exists
+ if (await client.Collections.Exists(collectionName))
+ {
+ await client.Collections.Delete(collectionName);
+ Console.WriteLine($"Deleted existing collection: '{collectionName}'");
+ }
+
+ // START CreateCollectionWithVectorizer
+ var articleCollection = new Collection
+ {
+ Name = collectionName,
+ Description = "something",
+ Properties = [Property.Int("number_property"),Property.Text("test_property")],
+ VectorConfig = new VectorConfig("vector_name", new Vectorizer.Text2VecContextionary())
+ };
+
+ var collection = await client.Collections.Create(articleCollection);
+ // END CreateCollectionWithVectorizer
+ Console.WriteLine($"Successfully created collection: '{collectionName}'");
+ }
+
+ [Fact]
+ public async Task Should_Delete_Collection()
+ {
+ var client = Connect.Local(restPort: 8085, grpcPort: 50055);
+ var collectionName = "Article";
+
+ // Ensure the collection exists before attempting to delete it
+ if (await client.Collections.Exists(collectionName))
+ {
+ await client.Collections.Delete(collectionName);
+ Console.WriteLine($"Successfully deleted collection: '{collectionName}'");
+ }
+ else
+ {
+ Console.WriteLine($"Collection '{collectionName}' does not exist.");
+ }
+ }
+}
diff --git a/_includes/code/csharp/ConnectionTests.cs b/_includes/code/csharp/ConnectionTests.cs
new file mode 100644
index 000000000..ed158de63
--- /dev/null
+++ b/_includes/code/csharp/ConnectionTests.cs
@@ -0,0 +1,27 @@
+using Xunit;
+using Weaviate.Client;
+using System;
+using System.Threading.Tasks;
+
+namespace WeaviateProject.Tests;
+
+public class ConnectionTest
+{
+ [Fact]
+ public async Task Should_Connect_To_Weaviate()
+ {
+ // START LocalNoAuth
+ var client = Connect.Local(restPort: 8085, grpcPort: 50055);
+ // END LocalNoAuth
+ // try
+ // {
+ // var meta = await client.GetMeta();
+ // Assert.NotNull(meta);
+ // Assert.NotNull(client);
+ // }
+ // catch (Exception ex)
+ // {
+ // Assert.True(false, $"Connection failed: {ex.Message}");
+ // }
+ }
+}
diff --git a/_includes/code/csharp/ObjectTests.cs b/_includes/code/csharp/ObjectTests.cs
new file mode 100644
index 000000000..e38e6a049
--- /dev/null
+++ b/_includes/code/csharp/ObjectTests.cs
@@ -0,0 +1,53 @@
+using Xunit;
+using Weaviate.Client;
+using System;
+using System.Threading.Tasks;
+using Weaviate.Client.Models;
+
+namespace WeaviateProject.Tests;
+
+public class ObjectTest
+{
+ readonly Guid objectId = Guid.NewGuid();
+ readonly string collectionName = "Jeopardy";
+
+ [Fact]
+ public async Task Should_Import_Objects()
+ {
+ var client = Connect.Local(restPort: 8085, grpcPort: 50055);
+ // START CreateObject
+ var collectionClient = client.Collections.Use(collectionName);
+
+ var obj = await collectionClient.Data.Insert(
+ new
+ {
+ question = "This vector DB is OSS & supports automatic property type inference on import",
+ // "answer": "Weaviate", # properties can be omitted
+ newProperty = 123
+ },
+ id: objectId
+ );
+ // END CreateObject
+ Console.WriteLine($"Successfully created collection: '{collectionName}'");
+ }
+
+ [Fact]
+ public async Task Should_Delete_Objects()
+ {
+ var client = Connect.Local(restPort: 8085, grpcPort: 50055);
+ var collectionName = "Article";
+
+ if (await client.Collections.Exists(collectionName))
+ {
+ // START DeleteObject
+ var collection = client.Collections.Use(collectionName);
+ await collection.Data.Delete(objectId);
+ // END DeleteObject
+ Console.WriteLine($"Successfully deleted object: '{objectId}' from collection: '{collectionName}'");
+ }
+ else
+ {
+ Console.WriteLine($"Collection '{collectionName}' does not exist.");
+ }
+ }
+}
diff --git a/_includes/code/csharp/SearchTests.cs b/_includes/code/csharp/SearchTests.cs
new file mode 100644
index 000000000..21f6be53c
--- /dev/null
+++ b/_includes/code/csharp/SearchTests.cs
@@ -0,0 +1,24 @@
+using Xunit;
+using Weaviate.Client;
+using System;
+using System.Threading.Tasks;
+using Weaviate.Client.Models;
+
+namespace WeaviateProject.Tests;
+
+public class SearchTest
+{
+ [Fact]
+ public async Task Should_Fetch_By_Id()
+ {
+ var client = Connect.Local(restPort: 8085, grpcPort: 50055);
+
+ }
+
+ [Fact]
+ public async Task Should_Near_Text()
+ {
+ var client = Connect.Local(restPort: 8085, grpcPort: 50055);
+
+ }
+}
diff --git a/_includes/code/csharp/WeaviateProject.Tests.csproj b/_includes/code/csharp/WeaviateProject.Tests.csproj
new file mode 100644
index 000000000..303926820
--- /dev/null
+++ b/_includes/code/csharp/WeaviateProject.Tests.csproj
@@ -0,0 +1,15 @@
+
+
+
+ net8.0
+ true
+
+
+
+
+
+
+
+
+
+
diff --git a/_includes/schema-delete-class.mdx b/_includes/schema-delete-class.mdx
index 04d6b9453..1890fba39 100644
--- a/_includes/schema-delete-class.mdx
+++ b/_includes/schema-delete-class.mdx
@@ -4,6 +4,7 @@ import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBl
import ManageCollectionsCode from '!!raw-loader!/_includes/code/howto/manage-data.collections.py';
import JavaCode from '!!raw-loader!/_includes/code/howto/java/src/test/java/io/weaviate/docs/manage-data.classes.java';
import JavaV6Code from '!!raw-loader!/_includes/code/java-v6/src/test/java/ManageCollectionsTest.java';
+import CSharpCode from "!!raw-loader!/_includes/code/csharp/CollectionTests.cs";
You can delete any unwanted collection(s), along with the data that they contain.
@@ -89,4 +90,12 @@ curl \
```
+
+
+
diff --git a/docs.sln b/docs.sln
new file mode 100644
index 000000000..c5ead1f30
--- /dev/null
+++ b/docs.sln
@@ -0,0 +1,32 @@
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.5.2.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_includes", "_includes", "{DE45C9AA-DBB3-91F8-540C-03A41DB425DA}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "code", "code", "{9186D019-DB3D-BB6C-536B-D636275C82A4}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WeaviateProject.Tests", "_includes\code\csharp\WeaviateProject.Tests.csproj", "{E1A0B893-B9C7-B0BB-27A1-C94B4D04BC73}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {E1A0B893-B9C7-B0BB-27A1-C94B4D04BC73}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {E1A0B893-B9C7-B0BB-27A1-C94B4D04BC73}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {E1A0B893-B9C7-B0BB-27A1-C94B4D04BC73}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {E1A0B893-B9C7-B0BB-27A1-C94B4D04BC73}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(NestedProjects) = preSolution
+ {9186D019-DB3D-BB6C-536B-D636275C82A4} = {DE45C9AA-DBB3-91F8-540C-03A41DB425DA}
+ {E1A0B893-B9C7-B0BB-27A1-C94B4D04BC73} = {9186D019-DB3D-BB6C-536B-D636275C82A4}
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {E51A6D01-9E9C-4B44-BE15-9ECBB531729D}
+ EndGlobalSection
+EndGlobal
diff --git a/docs/weaviate/connections/connect-local.mdx b/docs/weaviate/connections/connect-local.mdx
index ba5c11f6f..3d20e910d 100644
--- a/docs/weaviate/connections/connect-local.mdx
+++ b/docs/weaviate/connections/connect-local.mdx
@@ -17,6 +17,7 @@ import PyCodeV4 from "!!raw-loader!/_includes/code/connections/connect-python-v4
import TsCodeV3 from "!!raw-loader!/_includes/code/connections/connect-ts-v3.ts";
import JavaCode from "!!raw-loader!/_includes/code/connections/connect.java";
import JavaV6Code from "!!raw-loader!/_includes/code/java-v6/src/test/java/ConnectionTest.java";
+import CSharpCode from '!!raw-loader!/_includes/code/csharp/ConnectionTests.cs';
import ShellCode from "!!raw-loader!/_includes/code/connections/connect.sh";
import GoCode from "!!raw-loader!/_includes/code/connections/connect.go";
@@ -73,6 +74,14 @@ To connect to a local instance without authentication, follow these examples.
language="java"
/>
+
+
+
+
+
+
:::tip Production ready collections
@@ -152,6 +161,14 @@ For details, see:
language="java"
/>
+
+
+
## Create a collection with a vectorizer
diff --git a/docs/weaviate/manage-collections/vector-config.mdx b/docs/weaviate/manage-collections/vector-config.mdx
index de2c6581a..ac9bc5735 100644
--- a/docs/weaviate/manage-collections/vector-config.mdx
+++ b/docs/weaviate/manage-collections/vector-config.mdx
@@ -13,6 +13,7 @@ import TSCode from "!!raw-loader!/_includes/code/howto/manage-data.collections.t
import JavaCode from "!!raw-loader!/_includes/code/howto/java/src/test/java/io/weaviate/docs/manage-data.classes.java";
import JavaV6Code from "!!raw-loader!/_includes/code/java-v6/src/test/java/ManageCollectionsTest.java";
import GoCode from "!!raw-loader!/_includes/code/howto/go/docs/manage-data.classes_test.go";
+import CSharpCode from "!!raw-loader!/_includes/code/csharp/CollectionTests.cs";
import VectorConfigSyntax from "/_includes/vector-config-syntax.mdx";
@@ -73,6 +74,14 @@ Collection level settings override default values and general configuration para
language="java"
/>
+
+
+
## Specify vectorizer settings
diff --git a/docs/weaviate/manage-objects/create.mdx b/docs/weaviate/manage-objects/create.mdx
index e7f607945..07686f1c4 100644
--- a/docs/weaviate/manage-objects/create.mdx
+++ b/docs/weaviate/manage-objects/create.mdx
@@ -13,6 +13,7 @@ import TSCode from "!!raw-loader!/_includes/code/howto/manage-data.create.ts";
import JavaCode from "!!raw-loader!/_includes/code/howto/java/src/test/java/io/weaviate/docs/manage-data.create.java";
import JavaV6Code from "!!raw-loader!/_includes/code/java-v6/src/test/java/ManageObjectsCreateTest.java";
import GoCode from "!!raw-loader!/_includes/code/howto/go/docs/manage-data.create_test.go";
+import CSharpCode from "!!raw-loader!/_includes/code/csharp/ObjectTests.cs";
The examples on this page demonstrate how to create individual objects in Weaviate.
@@ -65,6 +66,14 @@ This example creates an object in the `JeopardyQuestion` collection.
language="java"
/>
+
+
+
diff --git a/docs/weaviate/manage-objects/delete.mdx b/docs/weaviate/manage-objects/delete.mdx
index 2506fee6c..bcd29c3c3 100644
--- a/docs/weaviate/manage-objects/delete.mdx
+++ b/docs/weaviate/manage-objects/delete.mdx
@@ -13,6 +13,7 @@ import TSCode from "!!raw-loader!/_includes/code/howto/manage-data.delete.ts";
import JavaCode from "!!raw-loader!/_includes/code/howto/java/src/test/java/io/weaviate/docs/manage-data.delete.java";
import JavaV6Code from "!!raw-loader!/_includes/code/java-v6/src/test/java/ManageObjectsDeleteTest.java";
import GoCode from "!!raw-loader!/_includes/code/howto/go/docs/manage-data.delete_test.go";
+import CSharpCode from "!!raw-loader!/_includes/code/csharp/ObjectTests.cs";
import SkipLink from "/src/components/SkipValidationLink";
Weaviate allows object deletion by id or by a set of criteria.
@@ -74,6 +75,14 @@ To delete by id, specify the collection name and the object id.
startMarker="// START DeleteObject"
endMarker="// END DeleteObject"
language="java"
+ />
+
+
+
diff --git a/docusaurus.config.js b/docusaurus.config.js
index 6d86cdd8e..f8bdbf2cd 100644
--- a/docusaurus.config.js
+++ b/docusaurus.config.js
@@ -151,7 +151,7 @@ const config = {
prism: {
theme: prismThemes.github,
darkTheme: prismThemes.dracula,
- additionalLanguages: ["java"],
+ additionalLanguages: ['java', 'csharp'],
},
docs: {
sidebar: {
From e92cc02b17f91d9dfa7658df9be5804a918d3d89 Mon Sep 17 00:00:00 2001
From: Ivan Despot <66276597+g-despot@users.noreply.github.com>
Date: Tue, 29 Jul 2025 10:31:16 +0200
Subject: [PATCH 02/18] Update docs
---
_includes/code/csharp/ObjectTests.cs | 1 -
_includes/code/csharp/SearchTests.cs | 36 ++++++++++++++++++++++++++--
docs/weaviate/search/basics.md | 16 +++++++++++++
docs/weaviate/search/similarity.md | 9 +++++++
4 files changed, 59 insertions(+), 3 deletions(-)
diff --git a/_includes/code/csharp/ObjectTests.cs b/_includes/code/csharp/ObjectTests.cs
index e38e6a049..f3dec072e 100644
--- a/_includes/code/csharp/ObjectTests.cs
+++ b/_includes/code/csharp/ObjectTests.cs
@@ -35,7 +35,6 @@ public async Task Should_Import_Objects()
public async Task Should_Delete_Objects()
{
var client = Connect.Local(restPort: 8085, grpcPort: 50055);
- var collectionName = "Article";
if (await client.Collections.Exists(collectionName))
{
diff --git a/_includes/code/csharp/SearchTests.cs b/_includes/code/csharp/SearchTests.cs
index 21f6be53c..04f287ad4 100644
--- a/_includes/code/csharp/SearchTests.cs
+++ b/_includes/code/csharp/SearchTests.cs
@@ -3,22 +3,54 @@
using System;
using System.Threading.Tasks;
using Weaviate.Client.Models;
+using System.Linq;
namespace WeaviateProject.Tests;
+public static class QueryConstants
+{
+ public const string NearTextQuery = "Weaviate";
+}
+
public class SearchTest
{
+ readonly WeaviateClient client = Connect.Local(restPort: 8085, grpcPort: 50055);
+
[Fact]
public async Task Should_Fetch_By_Id()
{
- var client = Connect.Local(restPort: 8085, grpcPort: 50055);
+ var collection = client.Collections.Use("JeopardyQuestion");
+ var objectId = Guid.NewGuid();
+ await collection.Data.Insert(
+ new
+ {
+ question = "This vector DB is OSS & supports automatic property type inference on import",
+ newProperty = 123
+ },
+ id: objectId
+ );
+ // START FetchById
+ var obj = await collection.Query.FetchObjectByID(objectId);
+ Console.WriteLine($"Fetched object with ID: {obj.ID}");
+ // END FetchById
}
[Fact]
public async Task Should_Near_Text()
{
- var client = Connect.Local(restPort: 8085, grpcPort: 50055);
+ // START GetNearText
+ var collection = client.Collections.Use("JeopardyQuestion");
+ var queryResult = await collection.Query.NearText(
+ "animals in movies",
+ limit: 2,
+ metadata: MetadataOptions.Distance);
+ Console.WriteLine("Search Results:");
+ foreach (var obj in queryResult.Objects)
+ {
+ Console.WriteLine($"Object: {obj.Properties})");
+ }
+ // END GetNearText
}
}
diff --git a/docs/weaviate/search/basics.md b/docs/weaviate/search/basics.md
index 6f843981c..c60b8ad41 100644
--- a/docs/weaviate/search/basics.md
+++ b/docs/weaviate/search/basics.md
@@ -14,6 +14,7 @@ import TSCode from '!!raw-loader!/\_includes/code/howto/search.basics.ts';
import GoCode from '!!raw-loader!/\_includes/code/howto/go/docs/mainpkg/search-basic_test.go';
import JavaV6Code from "!!raw-loader!/\_includes/code/java-v6/src/test/java/SearchBasicTest.java";
import JavaCode from '!!raw-loader!/\_includes/code/howto/java/src/test/java/io/weaviate/docs/search/BasicSearchTest.java';
+import CSharpCode from "!!raw-loader!/_includes/code/csharp/SearchTests.cs";
With Weaviate you can query your data using [vector similarity search](./similarity.md), [keyword search](./bm25.md), or a mix of both with [hybrid search](./hybrid.md). You can control what object [properties](#specify-object-properties) and [metadata](#retrieve-metadata-values) to return.
@@ -95,6 +96,21 @@ Specify the information that you want your query to return. You can return objec
+## Fetch objects by ID
+
+Fetch an object by its UUID:
+
+
+
+
+
+
+
## `limit` returned objects
Use `limit` to set a fixed maximum number of objects to return.
diff --git a/docs/weaviate/search/similarity.md b/docs/weaviate/search/similarity.md
index 91f04b1f4..3f2153104 100644
--- a/docs/weaviate/search/similarity.md
+++ b/docs/weaviate/search/similarity.md
@@ -14,6 +14,7 @@ import TSCode from '!!raw-loader!/\_includes/code/howto/search.similarity.ts';
import GoCode from '!!raw-loader!/\_includes/code/howto/go/docs/mainpkg/search-similarity_test.go';
import JavaCode from '!!raw-loader!/\_includes/code/howto/java/src/test/java/io/weaviate/docs/search/VectorSearchTest.java';
import JavaV6Code from "!!raw-loader!/\_includes/code/java-v6/src/test/java/SearchSimilarityTest.java";
+import CSharpCode from "!!raw-loader!/_includes/code/csharp/SearchTests.cs";
Vector search returns the objects with most similar vectors to that of the query.
@@ -70,6 +71,14 @@ Use the [`Near Text`](../api/graphql/search-operators.md#neartext) operator to f
language="graphql"
/>
+
+
+
From 266bfafb16140244524be163b16a24057b7664a7 Mon Sep 17 00:00:00 2001
From: Ivan Despot <66276597+g-despot@users.noreply.github.com>
Date: Tue, 29 Jul 2025 12:23:10 +0200
Subject: [PATCH 03/18] Update docs
---
_includes/code/csharp/CollectionTests.cs | 15 +++++-----
_includes/code/csharp/ConnectionTests.cs | 29 +++++++++++++++++++-
_includes/code/csharp/ObjectTests.cs | 4 +--
_includes/code/csharp/SearchTests.cs | 4 +--
docs/weaviate/connections/connect-custom.mdx | 9 ++++++
5 files changed, 49 insertions(+), 12 deletions(-)
diff --git a/_includes/code/csharp/CollectionTests.cs b/_includes/code/csharp/CollectionTests.cs
index 0934dbd15..814d3edb5 100644
--- a/_includes/code/csharp/CollectionTests.cs
+++ b/_includes/code/csharp/CollectionTests.cs
@@ -11,7 +11,7 @@ public class CollectionTest
[Fact]
public async Task Should_Create_Collection()
{
- var client = Connect.Local(restPort: 8085, grpcPort: 50055);
+ var client = Connect.Local(restPort: 8080, grpcPort: 50051);
// START BasicCreateCollection
var collectionName = "Article";
// END BasicCreateCollection
@@ -37,7 +37,7 @@ public async Task Should_Create_Collection()
[Fact]
public async Task Should_Create_Collection_With_Properties()
{
- var client = Connect.Local(restPort: 8085, grpcPort: 50055);
+ var client = Connect.Local(restPort: 8080, grpcPort: 50051);
// START CreateCollectionWithProperties
var collectionName = "Article";
// END CreateCollectionWithProperties
@@ -53,7 +53,8 @@ public async Task Should_Create_Collection_With_Properties()
{
Name = collectionName,
Description = "something",
- Properties = [Property.Int("number_property"),Property.Text("test_property")],
+ Properties = [Property.Int("number_property"), Property.Text("test_property")],
+ // Properties = [.. Property.FromCollection()], // For dynamic properties, you can use the FromCollection method
};
var collection = await client.Collections.Create(articleCollection);
@@ -64,7 +65,7 @@ public async Task Should_Create_Collection_With_Properties()
[Fact]
public async Task Should_Create_Collection_With_Vectorizer()
{
- var client = Connect.Local(restPort: 8085, grpcPort: 50055);
+ var client = Connect.Local(restPort: 8080, grpcPort: 50051);
// START CreateCollectionWithVectorizer
var collectionName = "Article";
// END CreateCollectionWithVectorizer
@@ -80,8 +81,8 @@ public async Task Should_Create_Collection_With_Vectorizer()
{
Name = collectionName,
Description = "something",
- Properties = [Property.Int("number_property"),Property.Text("test_property")],
- VectorConfig = new VectorConfig("vector_name", new Vectorizer.Text2VecContextionary())
+ Properties = [Property.Int("number_property"), Property.Text("test_property")],
+ VectorConfig = new VectorConfig("vector_name", new Vectorizer.Text2VecContextionary(), new VectorIndex.HNSW())
};
var collection = await client.Collections.Create(articleCollection);
@@ -92,7 +93,7 @@ public async Task Should_Create_Collection_With_Vectorizer()
[Fact]
public async Task Should_Delete_Collection()
{
- var client = Connect.Local(restPort: 8085, grpcPort: 50055);
+ var client = Connect.Local(restPort: 8080, grpcPort: 50051);
var collectionName = "Article";
// Ensure the collection exists before attempting to delete it
diff --git a/_includes/code/csharp/ConnectionTests.cs b/_includes/code/csharp/ConnectionTests.cs
index ed158de63..a65d4d1b9 100644
--- a/_includes/code/csharp/ConnectionTests.cs
+++ b/_includes/code/csharp/ConnectionTests.cs
@@ -11,7 +11,7 @@ public class ConnectionTest
public async Task Should_Connect_To_Weaviate()
{
// START LocalNoAuth
- var client = Connect.Local(restPort: 8085, grpcPort: 50055);
+ var client = Connect.Local(restPort: 8080, grpcPort: 50051);
// END LocalNoAuth
// try
// {
@@ -24,4 +24,31 @@ public async Task Should_Connect_To_Weaviate()
// Assert.True(false, $"Connection failed: {ex.Message}");
// }
}
+
+ [Fact]
+ public async Task Should_Custom_Connect_To_Weaviate()
+ {
+ // START CustomConnect
+ var config = new ClientConfiguration(
+ RestAddress: "localhost",
+ GrpcAddress: "localhost",
+ RestPort: 8080,
+ GrpcPort: 50051,
+ UseSsl: false,
+ ApiKey: null
+ );
+
+ var client = new WeaviateClient(config);
+ // END CustomConnect
+ // try
+ // {
+ // var meta = await client.GetMeta();
+ // Assert.NotNull(meta);
+ // Assert.NotNull(client);
+ // }
+ // catch (Exception ex)
+ // {
+ // Assert.True(false, $"Connection failed: {ex.Message}");
+ // }
+ }
}
diff --git a/_includes/code/csharp/ObjectTests.cs b/_includes/code/csharp/ObjectTests.cs
index f3dec072e..ac9323355 100644
--- a/_includes/code/csharp/ObjectTests.cs
+++ b/_includes/code/csharp/ObjectTests.cs
@@ -14,7 +14,7 @@ public class ObjectTest
[Fact]
public async Task Should_Import_Objects()
{
- var client = Connect.Local(restPort: 8085, grpcPort: 50055);
+ var client = Connect.Local(restPort: 8080, grpcPort: 50051);
// START CreateObject
var collectionClient = client.Collections.Use(collectionName);
@@ -34,7 +34,7 @@ public async Task Should_Import_Objects()
[Fact]
public async Task Should_Delete_Objects()
{
- var client = Connect.Local(restPort: 8085, grpcPort: 50055);
+ var client = Connect.Local(restPort: 8080, grpcPort: 50051);
if (await client.Collections.Exists(collectionName))
{
diff --git a/_includes/code/csharp/SearchTests.cs b/_includes/code/csharp/SearchTests.cs
index 04f287ad4..492e05390 100644
--- a/_includes/code/csharp/SearchTests.cs
+++ b/_includes/code/csharp/SearchTests.cs
@@ -14,7 +14,7 @@ public static class QueryConstants
public class SearchTest
{
- readonly WeaviateClient client = Connect.Local(restPort: 8085, grpcPort: 50055);
+ readonly WeaviateClient client = Connect.Local(restPort: 8080, grpcPort: 50051);
[Fact]
public async Task Should_Fetch_By_Id()
@@ -43,7 +43,7 @@ public async Task Should_Near_Text()
var collection = client.Collections.Use("JeopardyQuestion");
var queryResult = await collection.Query.NearText(
"animals in movies",
- limit: 2,
+ limit: 1,
metadata: MetadataOptions.Distance);
Console.WriteLine("Search Results:");
diff --git a/docs/weaviate/connections/connect-custom.mdx b/docs/weaviate/connections/connect-custom.mdx
index a3bc78956..1c6adefcd 100644
--- a/docs/weaviate/connections/connect-custom.mdx
+++ b/docs/weaviate/connections/connect-custom.mdx
@@ -12,6 +12,7 @@ import FilteredTextBlock from "@site/src/components/Documentation/FilteredTextBl
import PyCodeV4 from "!!raw-loader!/_includes/code/connections/connect-python-v4.py";
import TsCodeV3 from "!!raw-loader!/_includes/code/connections/connect-ts-v3.ts";
import JavaV6Code from "!!raw-loader!/_includes/code/java-v6/src/test/java/ConnectionTest.java";
+import CSharpCode from '!!raw-loader!/_includes/code/csharp/ConnectionTests.cs';
The [Python Client v4](/weaviate/client-libraries/python) and the [TypeScript Client v3](../client-libraries/typescript/index.mdx) provide helper methods for common connection types. They also provide custom methods for when you need additional connection configuration.
@@ -42,6 +43,14 @@ If you are using one of the other clients, the standard connection methods are c
language="java"
/>
+
+
+
## Environment variables
From 7c1527a5cc731445048ccdf1704b8a03e1ca17be Mon Sep 17 00:00:00 2001
From: Ivan Despot <66276597+g-despot@users.noreply.github.com>
Date: Tue, 19 Aug 2025 09:40:06 +0200
Subject: [PATCH 04/18] Update docs
---
_includes/code/csharp/CollectionTests.cs | 8 +-
_includes/code/csharp/ConnectionTests.cs | 166 ++++++++++++++----
_includes/code/csharp/ObjectTests.cs | 4 +-
_includes/code/csharp/SearchTests.cs | 4 +-
.../code/csharp/WeaviateProject.Tests.csproj | 2 +-
5 files changed, 140 insertions(+), 44 deletions(-)
diff --git a/_includes/code/csharp/CollectionTests.cs b/_includes/code/csharp/CollectionTests.cs
index 814d3edb5..f028e6481 100644
--- a/_includes/code/csharp/CollectionTests.cs
+++ b/_includes/code/csharp/CollectionTests.cs
@@ -8,7 +8,7 @@ namespace WeaviateProject.Tests;
public class CollectionTest
{
- [Fact]
+ // [Fact]
public async Task Should_Create_Collection()
{
var client = Connect.Local(restPort: 8080, grpcPort: 50051);
@@ -34,7 +34,7 @@ public async Task Should_Create_Collection()
Console.WriteLine($"Successfully created collection: '{collectionName}'");
}
- [Fact]
+ // [Fact]
public async Task Should_Create_Collection_With_Properties()
{
var client = Connect.Local(restPort: 8080, grpcPort: 50051);
@@ -62,7 +62,7 @@ public async Task Should_Create_Collection_With_Properties()
Console.WriteLine($"Successfully created collection: '{collectionName}'");
}
- [Fact]
+ // [Fact]
public async Task Should_Create_Collection_With_Vectorizer()
{
var client = Connect.Local(restPort: 8080, grpcPort: 50051);
@@ -90,7 +90,7 @@ public async Task Should_Create_Collection_With_Vectorizer()
Console.WriteLine($"Successfully created collection: '{collectionName}'");
}
- [Fact]
+ // [Fact]
public async Task Should_Delete_Collection()
{
var client = Connect.Local(restPort: 8080, grpcPort: 50051);
diff --git a/_includes/code/csharp/ConnectionTests.cs b/_includes/code/csharp/ConnectionTests.cs
index a65d4d1b9..b63dee49c 100644
--- a/_includes/code/csharp/ConnectionTests.cs
+++ b/_includes/code/csharp/ConnectionTests.cs
@@ -1,54 +1,150 @@
-using Xunit;
using Weaviate.Client;
using System;
using System.Threading.Tasks;
+using Xunit;
namespace WeaviateProject.Tests;
-public class ConnectionTest
+public class ConnectionSnippetsTest
{
+ ///
+ /// Test for local connection with a custom URL and port.
+ ///
[Fact]
- public async Task Should_Connect_To_Weaviate()
+ public async Task Should_Connect_With_Custom_URL()
{
- // START LocalNoAuth
- var client = Connect.Local(restPort: 8080, grpcPort: 50051);
- // END LocalNoAuth
- // try
- // {
- // var meta = await client.GetMeta();
- // Assert.NotNull(meta);
- // Assert.NotNull(client);
- // }
- // catch (Exception ex)
- // {
- // Assert.True(false, $"Connection failed: {ex.Message}");
- // }
+ // START CustomURL
+ // The Connect.Local() method defaults to "localhost".
+ // For a different host, you must use a custom configuration.
+ var config = new ClientConfiguration(
+ RestAddress: "127.0.0.1",
+ GrpcAddress: "127.0.0.1",
+ RestPort: 8080,
+ GrpcPort: 50051
+ );
+ var client = new WeaviateClient(config);
+ // END CustomURL
+
+ try
+ {
+ var meta = await client.GetMeta();
+ Assert.False(string.IsNullOrEmpty(meta.Version.ToString()));
+ }
+ catch (Exception ex)
+ {
+ Assert.Fail($"Connection failed: {ex.Message}");
+ }
}
+ ///
+ /// Test for a fully custom connection, typically for a cloud instance.
+ ///
[Fact]
- public async Task Should_Custom_Connect_To_Weaviate()
+ public async Task Should_Perform_Custom_Connection_With_ApiKey()
{
// START CustomConnect
- var config = new ClientConfiguration(
- RestAddress: "localhost",
- GrpcAddress: "localhost",
- RestPort: 8080,
- GrpcPort: 50051,
- UseSsl: false,
- ApiKey: null
+ // START ConnectWithApiKeyExample
+ var httpHost = Environment.GetEnvironmentVariable("WEAVIATE_HTTP_HOST");
+ var grpcHost = Environment.GetEnvironmentVariable("WEAVIATE_GRPC_HOST");
+ var weaviateApiKey = Environment.GetEnvironmentVariable("WEAVIATE_API_KEY");
+
+ var config = new ClientConfiguration(
+ RestAddress: httpHost, // Hostname for the HTTP API connection
+ RestPort: 443, // Default is 80, WCD uses 443
+ UseSsl: true, // Whether to use https (secure) for the HTTP API connection
+ GrpcAddress: grpcHost, // Hostname for the gRPC API connection
+ GrpcPort: 443, // Default is 50051, WCD uses 443
+ ApiKey: weaviateApiKey // API key for authentication
);
-
var client = new WeaviateClient(config);
// END CustomConnect
- // try
- // {
- // var meta = await client.GetMeta();
- // Assert.NotNull(meta);
- // Assert.NotNull(client);
- // }
- // catch (Exception ex)
- // {
- // Assert.True(false, $"Connection failed: {ex.Message}");
- // }
+ // END ConnectWithApiKeyExample
+
+ try
+ {
+ var meta = await client.GetMeta();
+ Assert.False(string.IsNullOrEmpty(meta.Version.ToString()));
+ }
+ catch (Exception ex)
+ {
+ Assert.Fail($"Connection failed: {ex.Message}");
+ }
+ }
+
+ ///
+ /// Test for connecting to Weaviate Cloud (WCD).
+ ///
+ [Fact]
+ public async Task Should_Connect_To_WCD_With_Api_Key()
+ {
+ // START APIKeyWCD
+ var weaviateUrl = Environment.GetEnvironmentVariable("WEAVIATE_URL");
+ var wcdApiKey = Environment.GetEnvironmentVariable("WEAVIATE_API_KEY");
+
+ var client = Connect.Cloud(
+ restEndpoint: weaviateUrl,
+ apiKey: wcdApiKey
+ );
+ // END APIKeyWCD
+
+ try
+ {
+ var meta = await client.GetMeta();
+ Assert.False(string.IsNullOrEmpty(meta.Version.ToString()));
+ }
+ catch (Exception ex)
+ {
+ Assert.Fail($"Connection failed: {ex.Message}");
+ }
+ }
+
+ ///
+ /// Test for a default local connection without authentication.
+ ///
+ [Fact]
+ public async Task Should_Connect_Locally_Without_Auth()
+ {
+ // START LocalNoAuth
+ var client = Connect.Local();
+ // END LocalNoAuth
+
+ try
+ {
+ var meta = await client.GetMeta();
+ Assert.False(string.IsNullOrEmpty(meta.Version.ToString()));
+ }
+ catch (Exception ex)
+ {
+ Assert.Fail($"Connection failed: {ex.Message}");
+ }
+ }
+
+ ///
+ /// Test for a local connection using an API key and non-default ports.
+ ///
+ // TODO[g-despot]: Broken for some reason
+ //[Fact]
+ public async Task Should_Connect_Locally_With_Auth()
+ {
+ // START LocalAuth
+ var localApiKey = Environment.GetEnvironmentVariable("WEAVIATE_LOCAL_API_KEY");
+
+ var client = Connect.Local(
+ restPort: 8099,
+ grpcPort: 50052,
+ useSsl: true,
+ apiKey: localApiKey
+ );
+ // END LocalAuth
+
+ try
+ {
+ var meta = await client.GetMeta();
+ Assert.False(string.IsNullOrEmpty(meta.Version.ToString()));
+ }
+ catch (Exception ex)
+ {
+ Assert.Fail($"Connection failed: {ex.Message}");
+ }
}
}
diff --git a/_includes/code/csharp/ObjectTests.cs b/_includes/code/csharp/ObjectTests.cs
index ac9323355..adf8ec4bc 100644
--- a/_includes/code/csharp/ObjectTests.cs
+++ b/_includes/code/csharp/ObjectTests.cs
@@ -11,7 +11,7 @@ public class ObjectTest
readonly Guid objectId = Guid.NewGuid();
readonly string collectionName = "Jeopardy";
- [Fact]
+ // [Fact]
public async Task Should_Import_Objects()
{
var client = Connect.Local(restPort: 8080, grpcPort: 50051);
@@ -31,7 +31,7 @@ public async Task Should_Import_Objects()
Console.WriteLine($"Successfully created collection: '{collectionName}'");
}
- [Fact]
+ // [Fact]
public async Task Should_Delete_Objects()
{
var client = Connect.Local(restPort: 8080, grpcPort: 50051);
diff --git a/_includes/code/csharp/SearchTests.cs b/_includes/code/csharp/SearchTests.cs
index 492e05390..1a93406cd 100644
--- a/_includes/code/csharp/SearchTests.cs
+++ b/_includes/code/csharp/SearchTests.cs
@@ -16,7 +16,7 @@ public class SearchTest
{
readonly WeaviateClient client = Connect.Local(restPort: 8080, grpcPort: 50051);
- [Fact]
+ // [Fact]
public async Task Should_Fetch_By_Id()
{
var collection = client.Collections.Use("JeopardyQuestion");
@@ -36,7 +36,7 @@ await collection.Data.Insert(
// END FetchById
}
- [Fact]
+ // [Fact]
public async Task Should_Near_Text()
{
// START GetNearText
diff --git a/_includes/code/csharp/WeaviateProject.Tests.csproj b/_includes/code/csharp/WeaviateProject.Tests.csproj
index 303926820..accde3e72 100644
--- a/_includes/code/csharp/WeaviateProject.Tests.csproj
+++ b/_includes/code/csharp/WeaviateProject.Tests.csproj
@@ -9,7 +9,7 @@
-
+
From 07bb34a40974218f92667f93afc3e60dce7bbe9f Mon Sep 17 00:00:00 2001
From: Ivan Despot <66276597+g-despot@users.noreply.github.com>
Date: Tue, 19 Aug 2025 11:37:13 +0200
Subject: [PATCH 05/18] New C# code
---
_includes/code/csharp/ConnectionTests.cs | 2 -
.../code/csharp/ManageCollectionsTests.cs | 499 ++++++++++++++++++
docs/weaviate/connections/connect-cloud.mdx | 9 +
docs/weaviate/connections/connect-local.mdx | 16 +
.../Documentation/FilteredTextBlock.js | 4 +
5 files changed, 528 insertions(+), 2 deletions(-)
create mode 100644 _includes/code/csharp/ManageCollectionsTests.cs
diff --git a/_includes/code/csharp/ConnectionTests.cs b/_includes/code/csharp/ConnectionTests.cs
index b63dee49c..f192a82ea 100644
--- a/_includes/code/csharp/ConnectionTests.cs
+++ b/_includes/code/csharp/ConnectionTests.cs
@@ -43,7 +43,6 @@ public async Task Should_Connect_With_Custom_URL()
public async Task Should_Perform_Custom_Connection_With_ApiKey()
{
// START CustomConnect
- // START ConnectWithApiKeyExample
var httpHost = Environment.GetEnvironmentVariable("WEAVIATE_HTTP_HOST");
var grpcHost = Environment.GetEnvironmentVariable("WEAVIATE_GRPC_HOST");
var weaviateApiKey = Environment.GetEnvironmentVariable("WEAVIATE_API_KEY");
@@ -58,7 +57,6 @@ public async Task Should_Perform_Custom_Connection_With_ApiKey()
);
var client = new WeaviateClient(config);
// END CustomConnect
- // END ConnectWithApiKeyExample
try
{
diff --git a/_includes/code/csharp/ManageCollectionsTests.cs b/_includes/code/csharp/ManageCollectionsTests.cs
new file mode 100644
index 000000000..01e001929
--- /dev/null
+++ b/_includes/code/csharp/ManageCollectionsTests.cs
@@ -0,0 +1,499 @@
+using Xunit;
+using Weaviate.Client;
+using Weaviate.Client.Models;
+using System;
+using System.Threading.Tasks;
+using System.Collections.Generic;
+
+public class ManageDataTests : IAsyncLifetime
+{
+ private readonly WeaviateClient weaviate;
+ private readonly List _collectionNamesToDelete = new List();
+
+ public ManageDataTests()
+ {
+ weaviate = new WeaviateClient(
+ new ClientConfiguration { RestAddress = "localhost", RestPort = 8080 }
+ );
+ }
+
+ private string AddTestCollection(string name)
+ {
+ _collectionNamesToDelete.Add(name);
+ return name;
+ }
+
+ public Task InitializeAsync() => Task.CompletedTask;
+
+ public async Task DisposeAsync()
+ {
+ foreach (string name in _collectionNamesToDelete)
+ {
+ await weaviate.Collections.Delete(name);
+ }
+ }
+
+ [Fact]
+ public async Task CreateBasicCollection()
+ {
+ string collectionName = AddTestCollection("Article");
+ await weaviate.Collections.Delete(collectionName);
+
+ // START BasicCreateCollection
+ Collection articleCollection = new Collection { Name = collectionName };
+ await weaviate.Collections.Create(articleCollection);
+ // END BasicCreateCollection
+
+ bool exists = await weaviate.Collections.Exists(collectionName);
+ Assert.True(exists);
+ }
+
+ [Fact]
+ public async Task CreateCollectionWithProperties()
+ {
+ string collectionName = AddTestCollection("Article");
+ await weaviate.Collections.Delete(collectionName);
+
+ // START CreateCollectionWithProperties
+ Collection articleCollection = new Collection
+ {
+ Name = collectionName,
+ Properties = new List
+ {
+ Property.Text("title"),
+ Property.Text("body"),
+ }
+ };
+ await weaviate.Collections.Create(articleCollection);
+ // END CreateCollectionWithProperties
+
+ Collection collection = await weaviate.Collections.Export(collectionName);
+ Assert.NotNull(collection);
+ Assert.Equal(2, collection.Properties.Count);
+ }
+
+ [Fact]
+ public async Task CreateCollectionWithVectorizer()
+ {
+ string collectionName = AddTestCollection("Article");
+ await weaviate.Collections.Delete(collectionName);
+
+ // START Vectorizer
+ Collection articleCollection = new Collection
+ {
+ Name = collectionName,
+ VectorConfig = Configure.Vectors.Text2VecOpenAI("default").New(),
+ Properties = new List
+ {
+ Property.Text("title"),
+ Property.Text("body"),
+ }
+ };
+ await weaviate.Collections.Create(articleCollection);
+ // END Vectorizer
+
+ Collection collection = await weaviate.Collections.Export(collectionName);
+ Assert.NotNull(collection.VectorConfig);
+ Assert.Equal("text2vec-openai", collection.VectorConfig["default"].Vectorizer.Identifier);
+ }
+
+ [Fact]
+ public async Task CreateCollectionWithNamedVectors()
+ {
+ string collectionName = AddTestCollection("ArticleNV");
+ await weaviate.Collections.Delete(collectionName);
+
+ // START BasicNamedVectors
+ Collection articleCollection = new Collection
+ {
+ Name = collectionName,
+ VectorConfig = new VectorConfigList
+ {
+ // TODO[g-despot]: How to specify source properties
+ //Configure.Vectors.Text2VecCohere(sourceProperties: new[] { "title" }).New("title"),
+ //Configure.Vectors.Text2VecOpenAI(sourceProperties: new[] { "title", "country" }).New("title_country"),
+ Configure.Vectors.SelfProvided("default"),
+ },
+ Properties = new List
+ {
+ Property.Text("title"),
+ Property.Text("country"),
+ }
+ };
+ await weaviate.Collections.Create(articleCollection);
+ // END BasicNamedVectors
+
+ Collection collection = await weaviate.Collections.Export(collectionName);
+ Assert.Equal(1, collection.VectorConfig.Count);
+ // Assert.Equal(new[] { "title" }, collection.VectorConfig["title"].Vectorizer.SourceProperties);
+ }
+
+ [Fact]
+ public async Task SetVectorIndexType()
+ {
+ string collectionName = AddTestCollection("Article");
+ await weaviate.Collections.Delete(collectionName);
+
+ // START SetVectorIndexType
+ Collection articleCollection = new Collection
+ {
+ Name = collectionName,
+ VectorConfig = new VectorConfigList
+ {
+ new VectorConfig(
+ name: "default",
+ vectorizer: new Vectorizer.Text2VecOpenAI(),
+ vectorIndexConfig: new VectorIndex.HNSW()
+ )
+ },
+ Properties = new List
+ {
+ Property.Text("title"),
+ Property.Text("body"),
+ }
+ };
+ await weaviate.Collections.Create(articleCollection);
+ // END SetVectorIndexType
+
+ Collection collection = await weaviate.Collections.Export(collectionName);
+ Assert.IsType(collection.VectorConfig["default"].VectorIndexConfig);
+ }
+
+ [Fact]
+ public async Task SetVectorIndexParams()
+ {
+ string collectionName = AddTestCollection("Article");
+ await weaviate.Collections.Delete(collectionName);
+
+ // START SetVectorIndexParams
+ Collection articleCollection = new Collection
+ {
+ Name = collectionName,
+ VectorConfig = new VectorConfigList
+ {
+ new VectorConfig(
+ name: "default",
+ vectorizer: new Vectorizer.Text2VecOpenAI(),
+ vectorIndexConfig: new VectorIndex.HNSW
+ {
+ EfConstruction = 300,
+ Distance = VectorIndexConfig.VectorDistance.Cosine,
+ FilterStrategy = VectorIndexConfig.VectorIndexFilterStrategy.Sweeping
+ }
+ )
+ }
+ };
+ await weaviate.Collections.Create(articleCollection);
+ // END SetVectorIndexParams
+
+ Collection collection = await weaviate.Collections.Export(collectionName);
+ VectorIndex.HNSW hnswConfig = Assert.IsType(collection.VectorConfig["default"].VectorIndexConfig);
+ Assert.Equal(300, hnswConfig.EfConstruction);
+ }
+
+ [Fact]
+ public async Task SetInvertedIndexParams()
+ {
+ string collectionName = AddTestCollection("Article");
+ await weaviate.Collections.Delete(collectionName);
+
+ // START SetInvertedIndexParams
+ Collection articleCollection = new Collection
+ {
+ Name = collectionName,
+ Properties = new List
+ {
+ Property.Text("title", indexFilterable: true, indexSearchable: true),
+ Property.Text("chunk", indexFilterable: true, indexSearchable: true),
+ Property.Int("chunk_number", indexRangeFilters: true),
+ },
+ InvertedIndexConfig = new InvertedIndexConfig
+ {
+ Bm25 = new BM25Config { B = 0.7f, K1 = 1.25f },
+ IndexNullState = true,
+ IndexPropertyLength = true,
+ IndexTimestamps = true,
+ }
+ };
+ await weaviate.Collections.Create(articleCollection);
+ // END SetInvertedIndexParams
+
+ Collection collection = await weaviate.Collections.Export(collectionName);
+ Assert.Equal(0.7f, collection.InvertedIndexConfig.Bm25.B);
+ Assert.Equal(1.25f, collection.InvertedIndexConfig.Bm25.K1);
+ }
+
+ [Fact]
+ public async Task SetAndReadModules()
+ {
+ string collectionName = AddTestCollection("Article");
+ await weaviate.Collections.Delete(collectionName);
+
+ // START SetReranker
+ Collection articleReranker = new Collection
+ {
+ Name = collectionName,
+ VectorConfig = Configure.Vectors.Text2VecOpenAI().New(),
+ RerankerConfig = new Reranker.Cohere()
+ };
+ await weaviate.Collections.Create(articleReranker);
+ // END SetReranker
+
+ Collection collectionConfig = await weaviate.Collections.Export(collectionName);
+ Assert.Equal("reranker-cohere", (collectionConfig.RerankerConfig as Reranker.Cohere)?.Type);
+
+ await weaviate.Collections.Delete(collectionName);
+
+ // START SetGenerative
+ Collection articleGenerative = new Collection
+ {
+ Name = collectionName,
+ VectorConfig = Configure.Vectors.Text2VecOpenAI().New(),
+ //TODO[g-despot]: Missing model parameter for generative OpenAIConfig
+ GenerativeConfig = new Generative.OpenAIConfig()
+ };
+ await weaviate.Collections.Create(articleGenerative);
+ // END SetGenerative
+
+ collectionConfig = await weaviate.Collections.Export(collectionName);
+ Assert.Equal("generative-openai", (collectionConfig.GenerativeConfig as Generative.OpenAIConfig)?.Type);
+ }
+
+ [Fact]
+ public async Task UpdateModules()
+ {
+ string collectionName = AddTestCollection("Article");
+ await weaviate.Collections.Delete(collectionName);
+
+ Collection initialCollection = new Collection
+ {
+ Name = collectionName,
+ VectorConfig = Configure.Vectors.Text2VecOpenAI().New(),
+ RerankerConfig = new Reranker.VoyageAI()
+ };
+ await weaviate.Collections.Create(initialCollection);
+
+ // START UpdateReranker
+ CollectionClient