Array of Document instances to be added to the table.
Promise that resolves when the documents are added.
Adds an array of vectors and corresponding documents to the database. The vectors and documents are batch inserted into the database.
Array of vectors to be added to the table.
Array of Document instances corresponding to the vectors.
Promise that resolves when the vectors and documents are added.
Checks if the specified column exists in the table and validates its data type and length.
The name of the table.
The name of the column to check.
The expected data type(s) of the column.
Optional
columnLength: numberThe expected length of the column. Optional.
Creates an HNSW vector index on a specified table and vector column with optional build and search configurations. If no configurations are provided, default parameters from the database are used. If provided values exceed the valid ranges, an error will be raised. The index is always created in ONLINE mode.
Object containing configuration options for the index
Optional
efConstruction?: number(Optional) Maximal candidates to consider when building the graph (Valid Range: [1, 100000])
Optional
efSearch?: number(Optional) Minimum candidates for top-k-nearest neighbor queries (Valid Range: [1, 100000])
Optional
indexName?: string(Optional) Custom index name. Defaults to <table_name>_<distance_strategy>_idx
Optional
m?: number(Optional) Maximum number of neighbors per graph node (Valid Range: [4, 1000])
Promise that resolves when index is added.
Deletes entries from the table based on the provided filter.
Return documents selected using the maximal marginal relevance. Maximal marginal relevance optimizes for similarity to the query AND diversity among selected documents.
Text to look up documents similar to.
Number of documents to return.
Number of documents to fetch before passing to the MMR algorithm.
Number between 0 and 1 that determines the degree of diversity among the results, where 0 corresponds to maximum diversity and 1 to minimum diversity.
List of documents selected by maximal marginal relevance.
Return docs most similar to query.
Query text for the similarity search.
Number of Documents to return. Defaults to 4.
Optional
filter: FilterA dictionary of metadata fields and values to filter by. Defaults to None.
Promise that resolves to a list of documents and their corresponding similarity scores.
Return docs most similar to the given embedding.
Number of Documents to return. Defaults to 4.
Optional
filter: FilterA dictionary of metadata fields and values to filter by. Defaults to None.
Promise that resolves to a list of documents and their corresponding similarity scores.
Return documents and score values most similar to query.
Query text for the similarity search.
Number of Documents to return. Defaults to 4.
Optional
filter: FilterA dictionary of metadata fields and values to filter by. Defaults to None.
Promise that resolves to a list of documents and their corresponding similarity scores.
Performs a similarity search based on vector comparison and returns documents along with their similarity scores and vectors.
The vector representation of the query for similarity comparison.
The number of top similar documents to return.
Optional
filter: FilterOptional filter criteria to apply to the search query.
A promise that resolves to an array of tuples, each containing a Document, its similarity score, and its vector.
Static
escapeStatic
fromCreates an instance of HanaDB
from an array of
Document instances. The documents are added to the database.
List of documents to be converted to vectors.
Embeddings instance used to convert the documents to vectors.
Configuration for the HanaDB.
Promise that resolves to an instance of HanaDB
.
Static
fromStatic method to create a HanaDB instance from raw texts. This method embeds the documents, creates a table if it does not exist, and adds the documents to the table.
Array of text documents to add.
metadata for each text document.
Configuration for the HanaDB.
A Promise that resolves to an instance of HanaDB.
Static
parseParses a string representation of a float array and returns an array of numbers.
The string representation of the array.
An array of floats parsed from the string.
Static
sanitizeSanitizes the input to integer. Throws an error if the value is less than lower bound.
The input to be sanitized.
The sanitized integer.
Static
sanitizeSanitizes a list to ensure all elements are floats (numbers in TypeScript). Throws an error if any element is not a number.
The array of numbers (floats) to be sanitized.
The sanitized array of numbers (floats).
Static
sanitizeSanitizes the input string by removing characters that are not alphanumeric or underscores.
The string to be sanitized.
The sanitized string.
Adds an array of documents to the table. The documents are first converted to vectors using the
embedDocuments
method of theembeddings
instance.