EmbeddingBasedDocumentStorage

A document storage implementation that utilizes embeddings for document ranking and retrieval. This class combines a document embedder for generating vector representations and a storage mechanism capable of associating documents with their respective embeddings. It provides ranking capabilities by measuring similarity between query embeddings and stored document embeddings.

Parameters

Document

The type of the document being stored and ranked.

Inheritors

Constructors

Link copied to clipboard
constructor(embedder: DocumentEmbedder<Document>, storage: VectorStorage<Document>)

Functions

Link copied to clipboard
open override fun allDocuments(): Flow<Document>

Retrieves a flow of all documents stored in the system.

Link copied to clipboard
Link copied to clipboard
open suspend override fun delete(documentId: String): Boolean

Deletes the document with the specified ID from the storage.

Link copied to clipboard
open suspend override fun getPayload(documentId: String)
Link copied to clipboard
open override fun rankDocuments(query: String): Flow<RankedDocument<Document>>

Ranks documents based on their similarity to a given query string.

Link copied to clipboard
open suspend override fun read(documentId: String): Document?

Reads a document by its unique identifier.

Link copied to clipboard
open suspend override fun readWithPayload(documentId: String): DocumentWithPayload<Document, Unit>?
Link copied to clipboard
open suspend fun store(document: Document): String

open suspend override fun store(document: Document, data: Unit): String

Stores the given document after embedding it into a vector representation.