constructor(embeddings: Embeddings, config: TypesenseConfig)
: Constructs a new instance of the Typesense
class.
embeddings
: An instance of the Embeddings
class used for embedding documents.config
: Configuration object for the Typesense vector store.
typesenseClient
: Typesense client instance.schemaName
: Name of the Typesense schema in which documents will be stored and searched.searchParams
(optional): Typesense search parameters. Default is { q: '*', per_page: 5, query_by: '' }
.columnNames
(optional): Column names configuration.
vector
(optional): Vector column name. Default is 'vec'
.pageContent
(optional): Page content column name. Default is 'text'
.metadataColumnNames
(optional): Metadata column names. Default is an empty array []
.import
(optional): Replace the default import function for importing data to Typesense. This can affect the functionality of updating documents.async addDocuments(documents: Document[]): Promise<void>
: Adds documents to the vector store. The documents will be updated if there is a document with the same ID.static async fromDocuments(docs: Document[], embeddings: Embeddings, config: TypesenseConfig): Promise<Typesense>
: Creates a Typesense vector store from a list of documents. Documents are added to the vector store during construction.static async fromTexts(texts: string[], metadatas: object[], embeddings: Embeddings, config: TypesenseConfig): Promise<Typesense>
: Creates a Typesense vector store from a list of texts and associated metadata. Texts are converted to documents and added to the vector store during construction.async similaritySearch(query: string, k?: number, filter?: Record<string, unknown>): Promise<Document[]>
: Searches for similar documents based on a query. Returns an array of similar documents.async deleteDocuments(documentIds: string[]): Promise<void>
: Deletes documents from the vector store based on their IDs.