Repository navigation
ExtensionsVectorData lodestarvectorstorecollection collectionexistsasync
Development build. This page describes
main, not a released package. The latest published Lodestar.Extensions.VectorData is 0.1.0 — read its documentation.
Home › ExtensionsVectorData › Vector store
Whether the collection has been ensured or written to.
public Task<bool> CollectionExistsAsync(CancellationToken cancellationToken = default)Parameters — cancellationToken is checked on entry: one already cancelled returns a cancelled
task (#1354).
Returns — a completed Task<bool>: true once
LodestarVectorStoreCollection.EnsureCollectionExistsAsync
or an upsert has run, and false again after
LodestarVectorStoreCollection.EnsureCollectionDeletedAsync.
Example — an upsert is enough to make a collection exist.
using Lodestar.Extensions.VectorData;
using Microsoft.Extensions.VectorData;
static async Task<string> ExistAsync()
{
using var notes = new LodestarVectorStoreCollection<string, Note>("notes");
bool constructed = await notes.CollectionExistsAsync();
await notes.UpsertAsync(new Note { Id = "a", Text = "a note", Embedding = new float[] { 1f, 0f, 0f } });
bool written = await notes.CollectionExistsAsync();
return $"{constructed} {written}";
}
string states = ExistAsync().GetAwaiter().GetResult(); // => False TrueRemarks — a server-backed provider answers this by asking the server whether a table or an index is there. An in-process collection has nothing to ask, so existence is a flag the collection keeps, set and cleared exactly where the abstraction says a server's would be. That is what lets code written against the abstraction run unchanged against this store.
Deleting every record does not clear it; only deleting the collection does.
Applies to — net10.0, netstandard2.0.
See also — LodestarVectorStore.CollectionExistsAsync,
LodestarVectorStoreCollection.