{"version":3,"file":"couchbase_search.d.ts","names":["EmbeddingsInterface","VectorStore","Cluster","Document","AddVectorOptions","Record","CouchbaseSearchVectorStoreArgs","CouchbaseSearchVectorStoreFilter","CouchbaseSearchVectorStore","Promise"],"sources":["../../src/vectorstores/couchbase_search.d.ts"],"sourcesContent":["import { EmbeddingsInterface } from \"@langchain/core/embeddings\";\nimport { VectorStore } from \"@langchain/core/vectorstores\";\nimport { Cluster } from \"couchbase\";\nimport { Document } from \"@langchain/core/documents\";\n/**\n * This interface define the optional fields for adding vector\n * - `ids` - vector of ids for each document. If undefined, then uuid will be used\n * - `metadata` - vector of metadata object for each document\n */\nexport interface AddVectorOptions {\n    ids?: string[];\n    metadata?: Record<string, any>[];\n}\n/**\n * This interface defines the fields required to initialize a vector store\n * These are the fields part of config:\n * @property {Cluster} cluster - The Couchbase cluster that the store will interact with.\n * @property {string} bucketName - The name of the bucket in the Couchbase cluster.\n * @property {string} scopeName - The name of the scope within the bucket.\n * @property {string} collectionName - The name of the collection within the scope.\n * @property {string} indexName - The name of the index to be used for vector search.\n * @property {string} textKey - The key to be used for text in the documents. Defaults to \"text\".\n * @property {string} embeddingKey - The key to be used for embeddings in the documents. Defaults to \"embedding\".\n * @property {boolean} scopedIndex - Whether to use a scoped index for vector search. Defaults to true.\n * @property {AddVectorOptions} addVectorOptions - Options for adding vectors with specific id/metadata\n */\nexport interface CouchbaseSearchVectorStoreArgs {\n    cluster: Cluster;\n    bucketName: string;\n    scopeName: string;\n    collectionName: string;\n    indexName: string;\n    textKey?: string;\n    embeddingKey?: string;\n    scopedIndex?: boolean;\n    addVectorOptions?: AddVectorOptions;\n}\n/**\n * This type defines the search filters used in couchbase vector search\n * - `fields`: Optional list of fields to include in the\n * metadata of results. Note that these need to be stored in the index.\n * If nothing is specified, defaults to all the fields stored in the index.\n * - `searchOptions`:  Optional search options that are passed to Couchbase search. Defaults to empty object.\n */\ntype CouchbaseSearchVectorStoreFilter = {\n    fields?: any;\n    searchOptions?: any;\n};\n/**\n * Class for interacting with the Couchbase database. It extends the\n * VectorStore class and provides methods for adding vectors and\n * documents, and searching for similar vectors.\n * Initiate the class using initialize() method.\n */\nexport declare class CouchbaseSearchVectorStore extends VectorStore {\n    FilterType: CouchbaseSearchVectorStoreFilter;\n    private metadataKey;\n    private readonly defaultTextKey;\n    private readonly defaultScopedIndex;\n    private readonly defaultEmbeddingKey;\n    private cluster;\n    private _bucket;\n    private _scope;\n    private _collection;\n    private bucketName;\n    private scopeName;\n    private collectionName;\n    private indexName;\n    private textKey;\n    private embeddingKey;\n    private scopedIndex;\n    /**\n     * The private constructor used to provide embedding to parent class.\n     * Initialize the class using static initialize() method\n     * @param embedding - object to generate embedding\n     * @param config -  the fields required to initialize a vector store\n     */\n    private constructor();\n    /**\n     * initialize class for interacting with the Couchbase database.\n     * It extends the VectorStore class and provides methods\n     * for adding vectors and documents, and searching for similar vectors.\n     * This also verifies the params\n     *\n     * @param embeddings - object to generate embedding\n     * @param config - the fields required to initialize a vector store\n     */\n    static initialize(embeddings: EmbeddingsInterface, config: CouchbaseSearchVectorStoreArgs): Promise<CouchbaseSearchVectorStore>;\n    private checkIndexExists;\n    private checkBucketExists;\n    private checkScopeAndCollectionExists;\n    _vectorstoreType(): string;\n    /**\n     * Formats couchbase metadata by removing `metadata.` from initials\n     * @param fields - all the fields of row\n     * @returns - formatted metadata fields\n     */\n    private formatMetadata;\n    /**\n     * Performs a similarity search on the vectors in the Couchbase database and returns the documents and their corresponding scores.\n     *\n     * @param queryEmbeddings - Embedding vector to look up documents similar to.\n     * @param k - Number of documents to return. Defaults to 4.\n     * @param filter - Optional search filter that are passed to Couchbase search. Defaults to empty object.\n     * - `fields`: Optional list of fields to include in the\n     * metadata of results. Note that these need to be stored in the index.\n     * If nothing is specified, defaults to all the fields stored in the index.\n     * - `searchOptions`:  Optional search options that are passed to Couchbase search. Defaults to empty object.\n     *\n     * @returns - Promise of list of [document, score] that are the most similar to the query vector.\n     *\n     * @throws If the search operation fails.\n     */\n    similaritySearchVectorWithScore(queryEmbeddings: number[], k?: number, filter?: CouchbaseSearchVectorStoreFilter): Promise<[Document, number][]>;\n    /**\n     * Return documents that are most similar to the vector embedding.\n     *\n     * @param queryEmbeddings - Embedding to look up documents similar to.\n     * @param k - The number of similar documents to return. Defaults to 4.\n     * @param filter - Optional search filter that are passed to Couchbase search. Defaults to empty object.\n     * - `fields`: Optional list of fields to include in the\n     * metadata of results. Note that these need to be stored in the index.\n     * If nothing is specified, defaults to all the fields stored in the index.\n     * - `searchOptions`:  Optional search options that are passed to Couchbase search. Defaults to empty object.\n     *\n     * @returns - A promise that resolves to an array of documents that match the similarity search.\n     */\n    similaritySearchByVector(queryEmbeddings: number[], k?: number, filter?: CouchbaseSearchVectorStoreFilter): Promise<Document[]>;\n    /**\n     * Return documents that are most similar to the query.\n     *\n     * @param query - Query to look up for similar documents\n     * @param k - The number of similar documents to return. Defaults to 4.\n     * @param filter - Optional search filter that are passed to Couchbase search. Defaults to empty object.\n     * - `fields`: Optional list of fields to include in the\n     * metadata of results. Note that these need to be stored in the index.\n     * If nothing is specified, defaults to all the fields stored in the index.\n     * - `searchOptions`:  Optional search options that are passed to Couchbase search. Defaults to empty object.\n     *\n     * @returns - Promise of list of documents that are most similar to the query.\n     */\n    similaritySearch(query: string, k?: number, filter?: CouchbaseSearchVectorStoreFilter): Promise<Document[]>;\n    /**\n     * Return documents that are most similar to the query with their scores.\n     *\n     * @param query - Query to look up for similar documents\n     * @param k - The number of similar documents to return. Defaults to 4.\n     * @param filter - Optional search filter that are passed to Couchbase search. Defaults to empty object.\n     * - `fields`: Optional list of fields to include in the\n     * metadata of results. Note that these need to be stored in the index.\n     * If nothing is specified, defaults to all the fields stored in the index.\n     * - `searchOptions`:  Optional search options that are passed to Couchbase search. Defaults to empty object.\n     *\n     * @returns - Promise of list of documents that are most similar to the query.\n     */\n    similaritySearchWithScore(query: string, k?: number, filter?: CouchbaseSearchVectorStoreFilter): Promise<[Document, number][]>;\n    private upsertDocuments;\n    /**\n     * Add vectors and corresponding documents to a couchbase collection\n     * If the document IDs are passed, the existing documents (if any) will be\n     * overwritten with the new ones.\n     * @param vectors - The vectors to be added to the collection.\n     * @param documents - The corresponding documents to be added to the collection.\n     * @param options - Optional parameters for adding vectors.\n     * This may include the IDs and metadata of the documents to be added. Defaults to an empty object.\n     *\n     * @returns - A promise that resolves to an array of document IDs that were added to the collection.\n     */\n    addVectors(vectors: number[][], documents: Document[], options?: AddVectorOptions): Promise<string[]>;\n    /**\n     * Run texts through the embeddings and persist in vectorstore.\n     * If the document IDs are passed, the existing documents (if any) will be\n     * overwritten with the new ones.\n     * @param documents - The corresponding documents to be added to the collection.\n     * @param options - Optional parameters for adding documents.\n     * This may include the IDs and metadata of the documents to be added. Defaults to an empty object.\n     *\n     * @returns - A promise that resolves to an array of document IDs that were added to the collection.\n     */\n    addDocuments(documents: Document[], options?: AddVectorOptions): Promise<string[]>;\n    /**\n     * Create a new CouchbaseVectorStore from a set of documents.\n     * This function will initialize a new store, add the documents to it, and then return the store.\n     * @param documents - The documents to be added to the new store.\n     * @param embeddings - The embeddings to be used for the documents.\n     * @param config - The configuration for the new CouchbaseVectorStore. This includes the options for adding vectors.\n     *\n     * @returns - A promise that resolves to the new CouchbaseVectorStore that contains the added documents.\n     */\n    static fromDocuments(documents: Document[], embeddings: EmbeddingsInterface, config: CouchbaseSearchVectorStoreArgs): Promise<CouchbaseSearchVectorStore>;\n    /**\n     * Create a new CouchbaseVectorStore from a set of texts.\n     * This function will convert each text and its corresponding metadata into a Document,\n     * initialize a new store, add the documents to it, and then return the store.\n     * @param texts - The texts to be converted into Documents and added to the new store.\n     * @param metadatas - The metadata for each text. If an array is passed, each text will have its corresponding metadata.\n     * If not, all texts will have the same metadata.\n     * @param embeddings - The embeddings to be used for the documents.\n     * @param config - The configuration for the new CouchbaseVectorStore. This includes the options for adding vectors.\n     *\n     * @returns - A promise that resolves to the new CouchbaseVectorStore that contains the added documents.\n     */\n    static fromTexts(texts: string[], metadatas: any, embeddings: EmbeddingsInterface, config: CouchbaseSearchVectorStoreArgs): Promise<CouchbaseSearchVectorStore>;\n    /**\n     * Delete documents asynchronously from the collection.\n     * This function will attempt to remove each document in the provided list of IDs from the collection.\n     * 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.\n     * @param ids - An array of document IDs to be deleted from the collection.\n     *\n     * @returns - A promise that resolves when all documents have been attempted to be deleted. If a document could not be deleted, an error is thrown.\n     */\n    delete(ids: string[]): Promise<void>;\n}\nexport {};\n//# sourceMappingURL=couchbase_search.d.ts.map"],"mappings":";;;;;;;;;AASA;AAiBA;AAUC;AAkBoBQ,UA7CJJ,gBAAAA,CA6C8B;EAC/BG,GAAAA,CAAAA,EAAAA,MAAAA,EAAAA;EAgCkBP,QAAAA,CAAAA,EA5EnBK,MA4EmBL,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA,EAAAA;;;;;;;;;;;;;;;AAoEmES,UAjIpFH,8BAAAA,CAiIoFG;EAatDN,OAAAA,EA7IlCD,OA6IkCC;EAAsBC,UAAAA,EAAAA,MAAAA;EAAmBK,SAAAA,EAAAA,MAAAA;EAW5DN,cAAAA,EAAAA,MAAAA;EAAsBC,SAAAA,EAAAA,MAAAA;EAAmBK,OAAAA,CAAAA,EAAAA,MAAAA;EAUjCN,YAAAA,CAAAA,EAAAA,MAAAA;EAAwBH,WAAAA,CAAAA,EAAAA,OAAAA;EAA6BM,gBAAAA,CAAAA,EA1JlEF,gBA0JkEE;;;;;;;;;AAvItB,KAV9DC,gCAAAA,GAU8D;;;;;;;;;;cAA9CC,0BAAAA,SAAmCP,WAAAA;cACxCM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAgCkBP,6BAA6BM,iCAAiCG,QAAQD;;;;;;;;;;;;;;;;;;;;;;;;;;kFA0BpBD,mCAAmCE,SAASN;;;;;;;;;;;;;;2EAcnDI,mCAAmCE,QAAQN;;;;;;;;;;;;;;uDAc/DI,mCAAmCE,QAAQN;;;;;;;;;;;;;;gEAclCI,mCAAmCE,SAASN;;;;;;;;;;;;;6CAa/DA,sBAAsBC,mBAAmBK;;;;;;;;;;;0BAW5DN,sBAAsBC,mBAAmBK;;;;;;;;;;kCAUjCN,wBAAwBH,6BAA6BM,iCAAiCG,QAAQD;;;;;;;;;;;;;gEAahER,6BAA6BM,iCAAiCG,QAAQD;;;;;;;;;yBAS7GC"}