VectorStoreCollection<TKey, TRecord> class
abstract
Represents a collection of records in a vector store.
Provides CRUD and similarity-search operations for a specific record type. Use VectorStore.getCollection to obtain an instance from a store.
Unless otherwise documented, implementations can be expected to be thread-safe and usable concurrently from multiple callers.
Example:
final collection = store.getCollection<String, Hotel>('hotels');
await collection.ensureCollectionExistsAsync();
final results = await collection
.searchAsync(embedding, top: 5)
.toList();
- Implemented types
-
- IVectorSearchable<
TRecord> - Disposable
- IVectorSearchable<
- Annotations
-
- @Source(name: 'VectorStoreCollection.cs', namespace: 'Microsoft.Extensions.VectorData', repository: 'dotnet/extensions', path: 'src/Libraries/Microsoft.Extensions.VectorData.Abstractions/VectorData/')
Constructors
Properties
Methods
-
collectionExistsAsync(
{CancellationToken? cancellationToken}) → Future< bool> - Returns true if the collection exists in the vector store.
-
deleteAsync(
TKey key, {CancellationToken? cancellationToken}) → Future< void> -
Deletes the record with the given
key. -
deleteBatchAsync(
Iterable< TKey> keys, {CancellationToken? cancellationToken}) → Future<void> -
Deletes all records whose keys are in
keys. -
dispose(
) → void -
Performs application-defined tasks associated with freeing, releasing,
or resetting unmanaged resources.
override
-
ensureCollectionDeletedAsync(
{CancellationToken? cancellationToken}) → Future< void> - Deletes the collection from the vector store if it exists.
-
ensureCollectionExistsAsync(
{CancellationToken? cancellationToken}) → Future< void> - Creates the collection in the vector store if it does not already exist.
-
getAsync(
TKey key, {RecordRetrievalOptions? options, CancellationToken? cancellationToken}) → Future< TRecord?> -
Gets the record with the given
key, or null if not found. -
getBatchAsync(
Iterable< TKey> keys, {RecordRetrievalOptions? options, CancellationToken? cancellationToken}) → Stream<TRecord> -
Gets all records whose keys are in
keys. -
getFilteredAsync(
{VectorStoreFilter? filter, int? top, FilteredRecordRetrievalOptions< TRecord> ? options, CancellationToken? cancellationToken}) → Stream<TRecord> -
Gets records matching an optional
filter. -
getService<
T> ({Object? key}) → T? -
Gets a service of the specified type provided by the underlying store.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
searchAsync<
TInput> (TInput value, {int top = 3, VectorSearchOptions< TRecord> ? options, CancellationToken? cancellationToken}) → Stream<VectorSearchResult< TRecord> > -
Searches for records that are similar to
value.override -
toString(
) → String -
A string representation of this object.
inherited
-
upsertAsync(
TRecord record, {CancellationToken? cancellationToken}) → Future< TKey> -
Inserts or updates
recordand returns its key. -
upsertBatchAsync(
Iterable< TRecord> records, {CancellationToken? cancellationToken}) → Stream<TKey> -
Inserts or updates each record in
recordsand yields the resulting keys.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited