Class for interacting with the Couchbase database. It extends the VectorStore class and provides methods for adding vectors and documents, and searching for similar vectors. Initiate the class using initialize() method.

Hierarchy

  • VectorStore
    • CouchbaseVectorStore

Properties

FilterType: CouchbaseVectorStoreFilter

Methods

  • Run texts through the embeddings and persist in vectorstore. If the document IDs are passed, the existing documents (if any) will be overwritten with the new ones.

    Parameters

    • documents: Document<Record<string, any>>[]

      The corresponding documents to be added to the collection.

    • options: AddVectorOptions = {}

      Optional parameters for adding documents. This may include the IDs and metadata of the documents to be added. Defaults to an empty object.

    Returns Promise<string[]>

    • A promise that resolves to an array of document IDs that were added to the collection.
  • Add vectors and corresponding documents to a couchbase collection If the document IDs are passed, the existing documents (if any) will be overwritten with the new ones.

    Parameters

    • vectors: number[][]

      The vectors to be added to the collection.

    • documents: Document<Record<string, any>>[]

      The corresponding documents to be added to the collection.

    • options: AddVectorOptions = {}

      Optional parameters for adding vectors. This may include the IDs and metadata of the documents to be added. Defaults to an empty object.

    Returns Promise<string[]>

    • A promise that resolves to an array of document IDs that were added to the collection.
  • Delete documents asynchronously from the collection. This function will attempt to remove each document in the provided list of IDs from the collection. If an error occurs during the deletion of a document, an error will be thrown with the ID of the document and the error message.

    Parameters

    • ids: string[]

      An array of document IDs to be deleted from the collection.

    Returns Promise<void>

    • A promise that resolves when all documents have been attempted to be deleted. If a document could not be deleted, an error is thrown.
  • Return documents that are most similar to the query.

    Parameters

    • query: string

      Query to look up for similar documents

    • k: number = 4

      The number of similar documents to return. Defaults to 4.

    • filter: CouchbaseVectorStoreFilter = {}

      Optional search filter that are passed to Couchbase search. Defaults to empty object.

      • fields: Optional list of fields to include in the metadata of results. Note that these need to be stored in the index. If nothing is specified, defaults to all the fields stored in the index.
      • searchOptions: Optional search options that are passed to Couchbase search. Defaults to empty object.

    Returns Promise<Document<Record<string, any>>[]>

    • Promise of list of documents that are most similar to the query.
  • Return documents that are most similar to the vector embedding.

    Parameters

    • queryEmbeddings: number[]

      Embedding to look up documents similar to.

    • k: number = 4

      The number of similar documents to return. Defaults to 4.

    • filter: CouchbaseVectorStoreFilter = {}

      Optional search filter that are passed to Couchbase search. Defaults to empty object.

      • fields: Optional list of fields to include in the metadata of results. Note that these need to be stored in the index. If nothing is specified, defaults to all the fields stored in the index.
      • searchOptions: Optional search options that are passed to Couchbase search. Defaults to empty object.

    Returns Promise<Document<Record<string, any>>[]>

    • A promise that resolves to an array of documents that match the similarity search.
  • Performs a similarity search on the vectors in the Couchbase database and returns the documents and their corresponding scores.

    Parameters

    • queryEmbeddings: number[]

      Embedding vector to look up documents similar to.

    • k: number = 4

      Number of documents to return. Defaults to 4.

    • filter: CouchbaseVectorStoreFilter = {}

      Optional search filter that are passed to Couchbase search. Defaults to empty object.

      • fields: Optional list of fields to include in the metadata of results. Note that these need to be stored in the index. If nothing is specified, defaults to all the fields stored in the index.
      • searchOptions: Optional search options that are passed to Couchbase search. Defaults to empty object.

    Returns Promise<[Document<Record<string, any>>, number][]>

    • Promise of list of [document, score] that are the most similar to the query vector.

    Throws

    If the search operation fails.

  • Return documents that are most similar to the query with their scores.

    Parameters

    • query: string

      Query to look up for similar documents

    • k: number = 4

      The number of similar documents to return. Defaults to 4.

    • filter: CouchbaseVectorStoreFilter = {}

      Optional search filter that are passed to Couchbase search. Defaults to empty object.

      • fields: Optional list of fields to include in the metadata of results. Note that these need to be stored in the index. If nothing is specified, defaults to all the fields stored in the index.
      • searchOptions: Optional search options that are passed to Couchbase search. Defaults to empty object.

    Returns Promise<[Document<Record<string, any>>, number][]>

    • Promise of list of documents that are most similar to the query.
  • Create a new CouchbaseVectorStore from a set of documents. This function will initialize a new store, add the documents to it, and then return the store.

    Parameters

    • documents: Document<Record<string, any>>[]

      The documents to be added to the new store.

    • embeddings: EmbeddingsInterface

      The embeddings to be used for the documents.

    • config: CouchbaseVectorStoreArgs

      The configuration for the new CouchbaseVectorStore. This includes the options for adding vectors.

    Returns Promise<CouchbaseVectorStore>

    • A promise that resolves to the new CouchbaseVectorStore that contains the added documents.
  • Create a new CouchbaseVectorStore from a set of texts. This function will convert each text and its corresponding metadata into a Document, initialize a new store, add the documents to it, and then return the store.

    Parameters

    • texts: string[]

      The texts to be converted into Documents and added to the new store.

    • metadatas: any

      The metadata for each text. If an array is passed, each text will have its corresponding metadata. If not, all texts will have the same metadata.

    • embeddings: EmbeddingsInterface

      The embeddings to be used for the documents.

    • config: CouchbaseVectorStoreArgs

      The configuration for the new CouchbaseVectorStore. This includes the options for adding vectors.

    Returns Promise<CouchbaseVectorStore>

    • A promise that resolves to the new CouchbaseVectorStore that contains the added documents.

Generated using TypeDoc