vector_data library
Vector store abstractions — a Dart port of
Microsoft.Extensions.VectorData.Abstractions.
Provides a provider-agnostic API for storing, retrieving, and searching records with vector embeddings. Use VectorStore to manage collections and VectorStoreCollection for CRUD and similarity search.
Collection Schema
The Dart port has no reflection-based schema discovery, so record shapes are always described explicitly:
// The Dart port has no reflection-based schema discovery, so the record
// shape is always described explicitly.
final definition = VectorStoreCollectionDefinition(
properties: [
VectorStoreKeyProperty('id'),
VectorStoreDataProperty('content')..isFullTextIndexed = true,
VectorStoreDataProperty('category')..isIndexed = true,
VectorStoreVectorProperty('embedding', dimensions: 1536)
..distanceFunction = DistanceFunction.cosineSimilarity
..indexKind = IndexKind.hnsw,
],
);
Filters
C# passes Expression<Func<TRecord, bool>>; Dart uses a sealed filter
hierarchy that providers pattern-match on:
// C# passes `Expression<Func<TRecord, bool>>`; Dart uses a sealed filter
// hierarchy that providers pattern-match on.
final filter = VectorStoreFilter.and([
VectorStoreFilter.equalTo('category', 'docs'),
VectorStoreFilter.or([
VectorStoreFilter.anyTagEqualTo('tags', 'dart'),
VectorStoreFilter.anyTagEqualTo('tags', 'flutter'),
]),
]);
Pair a filter with paging and ordering for filtered retrieval:
final options = FilteredRecordRetrievalOptions<Object>(
skip: 10,
includeVectors: false,
scoreThreshold: 0.75,
orderBy: const [
OrderByClause.descending('createdAt'),
OrderByClause.ascending('id'),
],
);
Classes
- AndVectorStoreFilter
- A filter that requires all filters to match.
- AnyTagEqualToFilterClause
- A filter clause that matches records where a collection field contains a specific string value.
- AnyTagEqualToVectorStoreFilter
- A filter that matches records where a collection field contains a specific string value.
- CollectionModel
- Represents the runtime model for a vector store record type.
- CollectionModelBuilder
- Builds a CollectionModel from a VectorStoreCollectionDefinition.
- CollectionModelBuildingOptions
- Options that control how a CollectionModel is built.
- DataPropertyModel
- Represents a data property on a vector store record.
- DistanceFunction
- Defines the distance functions that can be used to measure similarity between vectors in a vector store.
- EmbeddingGenerationDispatcher
- Encapsulates runtime embedding generation dispatch for a specific Embedding subtype.
- EqualToFilterClause
- A filter clause that matches records where a field equals a specific value.
- EqualToVectorStoreFilter
- A filter that matches records where a field equals a specific value.
- FilterClause
- Base class for filter clauses used when querying a vector store.
-
FilteredRecordRetrievalOptions<
TRecord> - Options for retrieving records from a vector store collection with optional filtering and ordering.
-
HybridSearchOptions<
TRecord> - Options for a hybrid vector-and-keyword search.
- IndexKind
- Defines the types of index that can be used to index vector data.
- KeyPropertyModel
- Represents a key property on a vector store record.
-
KeywordHybridSearchable<
TRecord> - Provides hybrid vector-and-keyword search over a collection of records.
- OrderByClause
- A clause that defines a single ordering direction for a field.
- OrVectorStoreFilter
- A filter that requires at least one of filters to match.
- PropertyModel
- Represents a property on a vector store record.
- RecordRetrievalOptions
- Options for retrieving records from a vector store collection by key.
- VectorDataStrings
- Error message factory for vector store provider implementations.
- VectorPropertyModel
- Represents a vector property on a vector store record.
-
VectorSearchable<
TRecord> - Provides vector similarity search over a collection of records.
-
VectorSearchOptions<
TRecord> - Options for a vector similarity search.
-
VectorSearchResult<
TRecord> - Represents a single result from a vector similarity search.
- VectorStore
- Represents a vector store that holds collections of records.
-
VectorStoreCollection<
TKey, TRecord> - Represents a collection of records in a vector store.
- VectorStoreCollectionDefinition
- Defines the schema of a vector store collection.
- VectorStoreCollectionMetadata
- Metadata about a vector store collection.
- VectorStoreCollectionOptions
- Base options for configuring a VectorStoreCollection.
- VectorStoreDataAttribute
- Marks a property on a record as a data field in a vector store collection.
- VectorStoreDataProperty
- Defines a data property in a vector store record.
- VectorStoreFilter
- Represents a filter to apply when querying a vector store collection.
- VectorStoreKeyAttribute
- Marks a property on a record as the key field in a vector store collection.
- VectorStoreKeyProperty
- Defines a key property in a vector store record.
- VectorStoreMetadata
- Metadata about a vector store instance.
- VectorStoreProperty
- Base class for all vector store record property definitions.
- VectorStoreVectorAttribute
- Marks a property on a record as a vector field in a vector store collection.
- VectorStoreVectorProperty
- Defines a vector property in a vector store record.
Typedefs
-
IKeywordHybridSearchable<
TRecord> = KeywordHybridSearchable< TRecord> - Former name of KeywordHybridSearchable, kept for backwards compatibility.
-
IVectorSearchable<
TRecord> = VectorSearchable< TRecord> - Former name of VectorSearchable, kept for backwards compatibility.
Exceptions / Errors
- VectorStoreException
- Represents an error that occurred while interacting with a vector store.