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.

Example:

import 'package:extensions/vector_data.dart';

// Define schema explicitly.
final definition = VectorStoreCollectionDefinition(
  properties: [
    VectorStoreKeyProperty('id'),
    VectorStoreDataProperty('content')..isFullTextIndexed = true,
    VectorStoreVectorProperty('embedding', dimensions: 1536),
  ],
);

// Obtain a typed collection from any VectorStore implementation.
final collection = store.getCollection<String, Hotel>(
  'hotels',
  definition: definition,
);

await collection.ensureCollectionExistsAsync();

// Search for similar records.
final results = await collection
  .searchAsync(
    queryEmbedding,
    top: 5,
    options: VectorSearchOptions(
      filter: VectorStoreFilter.equalTo('category', 'suite'),
      scoreThreshold: 0.75,
    ),
  )
  .toList();

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.
DistanceFunction
Defines the distance functions that can be used to measure similarity between vectors in a vector store.
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.
IKeywordHybridSearchable<TRecord>
Provides hybrid vector-and-keyword search over a collection of records.
IndexKind
Defines the types of index that can be used to index vector data.
IVectorSearchable<TRecord>
Provides vector similarity 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.
RecordRetrievalOptions
Options for retrieving records from a vector store collection by key.
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.

Exceptions / Errors

VectorStoreException
Represents an error that occurred while interacting with a vector store.