addDocument method
Add document with embedding to vector store
Auto-dimension detection:
- First document sets the dimension (e.g., 768D)
- Subsequent documents must match that dimension
INSERT OR REPLACE behavior:
- If
idexists, document is updated (replace) - If
idis new, document is inserted
Parameters:
id: Unique document identifier (PRIMARY KEY)content: Document text contentembedding: Vector embedding (dimension auto-detected from first add)metadata: Optional JSON string metadata
Throws:
- StateError if not initialized
- ArgumentError if embedding dimension doesn't match existing documents
Throws
VectorStoreExceptionif the store is initialized but holds on-disk data it could not read — an implementation must refuse rather than report an unreadable corpus as an empty one.
Implementation
@override
Future<void> addDocument({
required String id,
required String content,
required List<double> embedding,
String? metadata,
}) async {
throw UnimplementedError(
'WebSqliteVectorStore is only available on web; use SqliteVectorStore',
);
}