-
Notifications
You must be signed in to change notification settings - Fork 2
Cross-References #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Cross-References #13
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
638a1ba
* Remove collections after testing
mpartipilo 95615f2
Print headers before body
mpartipilo 4d110fc
Cross-references and other improvements
mpartipilo 1678ac8
Remove Collection Client from WeaviateObject
mpartipilo 98eb1ce
Remove unnecessary method overload
mpartipilo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| using Weaviate.Client.Models; | ||
|
|
||
| namespace Weaviate.Client.Tests.Integration; | ||
|
|
||
| public partial class BasicTests | ||
| { | ||
| [Fact] | ||
| public async Task CollectionCreation() | ||
| { | ||
| // Arrange | ||
|
|
||
| // Act | ||
| var collectionClient = await CollectionFactory("", "Test collection description", [ | ||
| Property.Text("Name") | ||
| ]); | ||
|
|
||
| // Assert | ||
| var collection = await _weaviate.Collections.Use<dynamic>(collectionClient.Name).Get(); | ||
| Assert.NotNull(collection); | ||
| Assert.Equal("CollectionCreation", collection.Name); | ||
| Assert.Equal("Test collection description", collection.Description); | ||
| } | ||
|
|
||
| [Fact] | ||
| public async Task ObjectCreation() | ||
| { | ||
| // Arrange | ||
| var collectionClient = await CollectionFactory<TestData>("", "Test collection description", [ | ||
| Property.Text("Name") | ||
| ]); | ||
|
|
||
| // Act | ||
| var id = Guid.NewGuid(); | ||
| var obj = await collectionClient.Data.Insert(new WeaviateObject<TestData>() | ||
| { | ||
| Data = new TestData { Name = "TestObject" }, | ||
| ID = id, | ||
| }); | ||
|
|
||
| // Assert | ||
|
|
||
| // Assert object exists | ||
| var retrieved = await collectionClient.Query.FetchObjectByID(id); | ||
| Assert.NotNull(retrieved); | ||
| Assert.Equal(id, retrieved.ID); | ||
| Assert.Equal("TestObject", retrieved.Data?.Name); | ||
|
|
||
| // Delete after usage | ||
| await collectionClient.Data.Delete(id); | ||
| retrieved = await collectionClient.Query.FetchObjectByID(id); | ||
| Assert.Null(retrieved); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
|
|
||
| using Weaviate.Client.Models; | ||
|
|
||
| namespace Weaviate.Client.Tests.Integration; | ||
|
|
||
| public partial class BasicTests | ||
| { | ||
| [Fact] | ||
| public async Task NearTextSearch() | ||
| { | ||
| // Arrange | ||
| var collectionClient = await CollectionFactory<TestDataValue>("", "Test collection description", [ | ||
| Property.Text("value") | ||
| ], vectorConfig: new Dictionary<string, VectorConfig> | ||
| { | ||
| { | ||
| "default", new VectorConfig | ||
| { | ||
| Vectorizer = new Dictionary<string, object> { | ||
| { | ||
| "text2vec-contextionary", new { | ||
| vectorizeClassName = false | ||
| } | ||
| } | ||
| }, | ||
| VectorIndexType = "hnsw" | ||
| } | ||
| } | ||
| }); | ||
|
|
||
| string[] values = ["Apple", "Mountain climbing", "apple cake", "cake"]; | ||
| var tasks = values.Select(s => new TestDataValue { Value = s }) | ||
| .Select(DataFactory) | ||
| .Select(d => collectionClient.Data.Insert(d)); | ||
| Guid[] guids = await Task.WhenAll(tasks); | ||
| var concepts = "hiking"; | ||
|
|
||
| // Act | ||
| var retriever = collectionClient.Query.NearText( | ||
| "cake", | ||
| moveTo: new Move(1.0f, objects: guids[0]), | ||
| moveAway: new Move(0.5f, concepts: concepts), | ||
| fields: ["value"], | ||
| metadata: new MetadataQuery(Vectors: new HashSet<string>(["default"])) | ||
| ); | ||
| var retrieved = await retriever.ToListAsync(TestContext.Current.CancellationToken); | ||
|
|
||
| // Assert | ||
| Assert.NotNull(retrieved); | ||
| Assert.Equal(4, retrieved.Count()); | ||
|
|
||
| Assert.Equal(retrieved[0].ID, guids[2]); | ||
| Assert.Contains("default", retrieved[0].Vectors.Keys); | ||
| Assert.Equal("apple cake", retrieved[0].Data?.Value); | ||
| } | ||
|
|
||
| [Fact] | ||
| public async Task NearTextGroupBySearch() | ||
| { | ||
| // Arrange | ||
| CollectionClient<dynamic>? collectionClient = await CollectionFactory("", "Test collection description", [ | ||
| Property.Text("value") | ||
| ], vectorConfig: new Dictionary<string, VectorConfig> | ||
| { | ||
| { | ||
| "default", new VectorConfig | ||
| { | ||
| Vectorizer = new Dictionary<string, object> { | ||
| { | ||
| "text2vec-contextionary", new { | ||
| vectorizeClassName = false | ||
| } | ||
| } | ||
| }, | ||
| VectorIndexType = "hnsw" | ||
| } | ||
| } | ||
| }); | ||
|
|
||
| string[] values = ["Apple", "Mountain climbing", "apple cake", "cake"]; | ||
| var tasks = values.Select(s => new { Value = s }) | ||
| .Select(DataFactory<dynamic>) | ||
| .Select(d => collectionClient.Data.Insert(d)); | ||
| Guid[] guids = await Task.WhenAll(tasks); | ||
|
|
||
| // Act | ||
| var retrieved = await collectionClient.Query.NearText( | ||
dirkkul marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "cake", | ||
| new GroupByConstraint | ||
| { | ||
| PropertyName = "value", | ||
| NumberOfGroups = 2, | ||
| ObjectsPerGroup = 100, | ||
| }, | ||
| metadata: new MetadataQuery(Vectors: ["default"]) | ||
| ); | ||
|
|
||
| // Assert | ||
| Assert.NotNull(retrieved.Objects); | ||
| Assert.NotNull(retrieved.Groups); | ||
|
|
||
| var retrievedObjects = retrieved.Objects.ToArray(); | ||
|
|
||
| Assert.Equal(2, retrieved.Objects.Count()); | ||
| Assert.Equal(2, retrieved.Groups.Count()); | ||
|
|
||
| var obj = await collectionClient.Query.FetchObjectByID(guids[3], metadata: new MetadataQuery(Vectors: ["default"])); | ||
| Assert.NotNull(obj); | ||
| Assert.Equal(guids[3], obj.ID); | ||
| Assert.Contains("default", obj.Vectors.Keys); | ||
|
|
||
| Assert.Equal(guids[3], retrievedObjects[0].ID); | ||
| Assert.Contains("default", retrievedObjects[0].Vectors.Keys); | ||
| Assert.Equal("cake", retrievedObjects[0].BelongsToGroup); | ||
| Assert.Equal(guids[2], retrievedObjects[1].ID); | ||
| Assert.Contains("default", retrievedObjects[1].Vectors.Keys); | ||
| Assert.Equal("apple cake", retrievedObjects[1].BelongsToGroup); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| using Weaviate.Client.Models; | ||
|
|
||
| namespace Weaviate.Client.Tests.Integration; | ||
|
|
||
| public partial class BasicTests | ||
| { | ||
|
|
||
| [Fact] | ||
| public async Task NearVectorSearch() | ||
| { | ||
| // Arrange | ||
| var collectionClient = await CollectionFactory<TestData>("", "Test collection description", [ | ||
| Property.Text("Name") | ||
| ]); | ||
|
|
||
| // Act | ||
| await collectionClient.Data.Insert(new WeaviateObject<TestData>() | ||
| { | ||
| Data = new TestData { Name = "TestObject1" }, | ||
| Vectors = new Dictionary<string, IList<float>> | ||
| { | ||
| { "default", new float[] { 0.1f, 0.2f, 0.3f } } | ||
| } | ||
| }); | ||
|
|
||
| await collectionClient.Data.Insert(new WeaviateObject<TestData>() | ||
| { | ||
| Data = new TestData { Name = "TestObject2" }, | ||
| Vectors = new Dictionary<string, IList<float>> | ||
| { | ||
| { "default", new float[] { 0.3f, 0.4f, 0.5f } } | ||
| } | ||
| }); | ||
|
|
||
| await collectionClient.Data.Insert(new WeaviateObject<TestData>() | ||
| { | ||
| Data = new TestData { Name = "TestObject3" }, | ||
| Vectors = new Dictionary<string, IList<float>> | ||
| { | ||
| { "default", new float[] { 0.5f, 0.6f, 0.7f } } | ||
| } | ||
| }); | ||
|
|
||
| // Assert | ||
| var retrieved = collectionClient.Query.NearVector(new float[] { 0.1f, 0.2f, 0.3f }); | ||
| Assert.NotNull(retrieved); | ||
|
|
||
| await foreach (var obj in retrieved) | ||
| { | ||
| Assert.Equal("TestObject1", obj.Data!.Name); | ||
| break; | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.