Skip to content

Add Vector Collection docs [API-2277] #958

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/dev/doc/distributed-objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Distributed objects are managed by an Hazelcast cluster, and accessed via the Ha
* [HRingBuffer](distributed-objects/hringbuffer.md) - a distributed ring-buffer corresponding to a cluster-side [Map](https://docs.hazelcast.com/hazelcast/latest/data-structures/ringbuffer)
* [HSet](distributed-objects/hset.md) - a distributed set store corresponding to a cluster-side [Set](https://docs.hazelcast.com/hazelcast/latest/data-structures/set)
* [HTopic](distributed-objects/htopic.md) - a distributed message-publishing store corresponding to a cluster-side [Topic](https://docs.hazelcast.com/hazelcast/latest/data-structures/topic)
* [HVectorCollection](distributed-objects/vectorcollection.md) - a distributed vector collection store corresponding to a cluster-side [Vector Collection](https://docs.hazelcast.com/hazelcast/latest/data-structures/vector-collections)

Distributed objects are obtained from the Hazelcast .NET Client and are fully identified by their unique name. If an object of the specified type and with the specified name already exists on the cluster, it is returned, otherwise it is created on the cluster. For instance:

Expand Down
73 changes: 73 additions & 0 deletions doc/dev/doc/distributed-objects/vectorcollection.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Vector Collection

![Note] This feature is available in Hazelcast Enterprise.

A `VectorCollection` is a collection of `VectorDocument` objects. For more information see
[the vector collection documentation](https://docs.hazelcast.com/hazelcast/latest/data-structures/vector-collections#hide-nav).

In order to use vector collection, you should configure the vector collection in the member. For more information see
[the vector collection configuration](https://docs.hazelcast.com/hazelcast/latest/data-structures/vector-collections#configuration).


## Creating a Vector Collection

After creating a Hazelcast .Net client and configuring the Hazelcast cluster, you can create a `VectorCollection` as follows:

```csharp
await using var vectorCollection = await client.GetVectorCollectionAsync<string, HazelcastJsonValue>("vector-example");
```

### Adding a Document to the Vector Collection

You can add a document to the vector collection as follows:

```csharp
var metaData = new HazelcastJsonValue("{\"name\": \"John\", \"age\": 25}");

var vectorDoc = VectorDocument<HazelcastJsonValue>
.Of(metaData, VectorValues.Of(new float[] { 0.1f, 0.2f, 0.3f }));

await vectorCollection.SetAsync("person-1", vectorDoc);
```

_*The vector values should be generated by a model._

### Getting a Document from the Vector Collection

You can get a document from the vector collection as follows:

```csharp
var vectorDoc = await vectorCollection.GetAsync("person-1");
```

### Removing a Document from the Vector Collection

You can remove a document from the vector collection as follows:

```csharp
await vectorCollection.RemoveAsync("person-1");
```

### Querying the Vector Collection

You can query the vector collection as follows:

```csharp
var queryVector = VectorValues.Of(new float[] { 0.1f, 0.2f, 0.3f });

var result = await vectorCollection.SearchAsync(queryVector,
new VectorSearchOptions(includeVectors: true,
includeValue: true,
limit: 3
));

foreach (var entry in result.Results)
{
// Do something with the result
}
```

After generating the vector that you like query, you also define the search options for additional information.


For hands-on experience, you can check the [Vector Collection Example](https://github.com/hazelcast/hazelcast-csharp-client/blob/master/src/Hazelcast.Net.Examples/DistributedObjects/VectorCollectionExample.cs).
1 change: 1 addition & 0 deletions doc/dev/doc/toc.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
## [FencedLock](distributed-objects/fencedlock.md)
## [CPMap](distributed-objects/cpmap.md)
## [CountDownLatch](distributed-objects/countdownlatch.md)
## [VectorCollection](distributed-objects/vectorcollection.md)
# [Distributed Computing](distributedComputing.md)
# [Distributed Query](distributedQuery.md)
# [CP SubSystem](cpsubsystem.md)
Expand Down
Loading