{"version":3,"file":"elasticsearch.d.cts","names":["Client","EmbeddingsInterface","VectorStore","Document","Callbacks","ElasticKnnEngine","ElasticSimilarity","VectorSearchOptions","HybridRetrievalStrategyConfig","HybridRetrievalStrategy","ElasticClientArgs","ElasticFilter","ElasticVectorSearch","Promise"],"sources":["../../src/vectorstores/elasticsearch.d.ts"],"sourcesContent":["import { Client } from \"@elastic/elasticsearch\";\nimport type { EmbeddingsInterface } from \"@langchain/core/embeddings\";\nimport { VectorStore } from \"@langchain/core/vectorstores\";\nimport { Document } from \"@langchain/core/documents\";\nimport type { Callbacks } from \"@langchain/core/callbacks/manager\";\n/**\n * Type representing the k-nearest neighbors (k-NN) engine used in\n * Elasticsearch.\n */\ntype ElasticKnnEngine = \"hnsw\";\n/**\n * Type representing the similarity measure used in Elasticsearch.\n */\ntype ElasticSimilarity = \"l2_norm\" | \"dot_product\" | \"cosine\";\n/**\n * Interface defining the options for vector search in Elasticsearch.\n */\ninterface VectorSearchOptions {\n    readonly engine?: ElasticKnnEngine;\n    readonly similarity?: ElasticSimilarity;\n    readonly m?: number;\n    readonly efConstruction?: number;\n    readonly candidates?: number;\n}\n/**\n * Configuration options for hybrid retrieval strategy.\n */\nexport interface HybridRetrievalStrategyConfig {\n    rankWindowSize?: number;\n    rankConstant?: number;\n    textField?: string;\n}\n/**\n * Hybrid search strategy combining vector and BM25 search using RRF.\n */\nexport declare class HybridRetrievalStrategy {\n    readonly rankWindowSize: number;\n    readonly rankConstant: number;\n    readonly textField: string;\n    constructor(config?: HybridRetrievalStrategyConfig);\n}\n/**\n * Interface defining the arguments required to create an Elasticsearch\n * client.\n */\nexport interface ElasticClientArgs {\n    readonly client: Client;\n    readonly indexName?: string;\n    readonly vectorSearchOptions?: VectorSearchOptions;\n    readonly strategy?: HybridRetrievalStrategy;\n}\n/**\n * Type representing a filter object in Elasticsearch.\n */\ntype ElasticFilter = object | {\n    field: string;\n    operator: string;\n    value: any;\n}[];\n/**\n * Elasticsearch vector store supporting vector and hybrid search.\n *\n * Hybrid search combines kNN vector search with BM25 full-text search\n * using RRF. Enable by passing a `HybridRetrievalStrategy` to the constructor.\n *\n * @example\n * ```typescript\n * // Vector search (default)\n * const vectorStore = new ElasticVectorSearch(embeddings, { client, indexName });\n *\n * // Hybrid search\n * const hybridStore = new ElasticVectorSearch(embeddings, {\n *   client,\n *   indexName,\n *   strategy: new HybridRetrievalStrategy()\n * });\n * ```\n */\nexport declare class ElasticVectorSearch extends VectorStore {\n    FilterType: ElasticFilter;\n    private readonly client;\n    private readonly indexName;\n    private readonly engine;\n    private readonly similarity;\n    private readonly efConstruction;\n    private readonly m;\n    private readonly candidates;\n    private readonly strategy?;\n    private lastQueryText?;\n    _vectorstoreType(): string;\n    constructor(embeddings: EmbeddingsInterface, args: ElasticClientArgs);\n    /**\n     * Method to add documents to the Elasticsearch database. It first\n     * converts the documents to vectors using the embeddings, then adds the\n     * vectors to the database.\n     * @param documents The documents to add to the database.\n     * @param options Optional parameter that can contain the IDs for the documents.\n     * @returns A promise that resolves with the IDs of the added documents.\n     */\n    addDocuments(documents: Document[], options?: {\n        ids?: string[];\n    }): Promise<string[]>;\n    /**\n     * Method to add vectors to the Elasticsearch database. It ensures the\n     * index exists, then adds the vectors and their corresponding documents\n     * to the database.\n     * @param vectors The vectors to add to the database.\n     * @param documents The documents corresponding to the vectors.\n     * @param options Optional parameter that can contain the IDs for the documents.\n     * @returns A promise that resolves with the IDs of the added documents.\n     */\n    addVectors(vectors: number[][], documents: Document[], options?: {\n        ids?: string[];\n    }): Promise<string[]>;\n    similaritySearch(query: string, k?: number, filter?: ElasticFilter, _callbacks?: Callbacks): Promise<Document[]>;\n    /**\n     * Method to perform a similarity search in the Elasticsearch database\n     * using a vector. It returns the k most similar documents along with\n     * their similarity scores.\n     * @param query The query vector.\n     * @param k The number of most similar documents to return.\n     * @param filter Optional filter to apply to the search.\n     * @returns A promise that resolves with an array of tuples, where each tuple contains a Document and its similarity score.\n     */\n    similaritySearchVectorWithScore(query: number[], k: number, filter?: ElasticFilter): Promise<[Document, number][]>;\n    private hybridSearchVectorWithScore;\n    /**\n     * Method to delete documents from the Elasticsearch database.\n     * @param params Object containing the IDs of the documents to delete.\n     * @returns A promise that resolves when the deletion is complete.\n     */\n    delete(params: {\n        ids: string[];\n    }): Promise<void>;\n    /**\n     * Static method to create an ElasticVectorSearch instance from texts. It\n     * creates Document instances from the texts and their corresponding\n     * metadata, then calls the fromDocuments method to create the\n     * ElasticVectorSearch instance.\n     * @param texts The texts to create the ElasticVectorSearch instance from.\n     * @param metadatas The metadata corresponding to the texts.\n     * @param embeddings The embeddings to use for the documents.\n     * @param args The arguments to create the Elasticsearch client.\n     * @returns A promise that resolves with the created ElasticVectorSearch instance.\n     */\n    static fromTexts(texts: string[], metadatas: object[] | object, embeddings: EmbeddingsInterface, args: ElasticClientArgs): Promise<ElasticVectorSearch>;\n    /**\n     * Static method to create an ElasticVectorSearch instance from Document\n     * instances. It adds the documents to the Elasticsearch database, then\n     * returns the ElasticVectorSearch instance.\n     * @param docs The Document instances to create the ElasticVectorSearch instance from.\n     * @param embeddings The embeddings to use for the documents.\n     * @param dbConfig The configuration for the Elasticsearch database.\n     * @returns A promise that resolves with the created ElasticVectorSearch instance.\n     */\n    static fromDocuments(docs: Document[], embeddings: EmbeddingsInterface, dbConfig: ElasticClientArgs): Promise<ElasticVectorSearch>;\n    /**\n     * Static method to create an ElasticVectorSearch instance from an\n     * existing index in the Elasticsearch database. It checks if the index\n     * exists, then returns the ElasticVectorSearch instance if it does.\n     * @param embeddings The embeddings to use for the documents.\n     * @param dbConfig The configuration for the Elasticsearch database.\n     * @returns A promise that resolves with the created ElasticVectorSearch instance if the index exists, otherwise it throws an error.\n     */\n    static fromExistingIndex(embeddings: EmbeddingsInterface, dbConfig: ElasticClientArgs): Promise<ElasticVectorSearch>;\n    private ensureIndexExists;\n    private buildMetadataTerms;\n    /**\n     * Method to check if an index exists in the Elasticsearch database.\n     * @returns A promise that resolves with a boolean indicating whether the index exists.\n     */\n    doesIndexExist(): Promise<boolean>;\n    /**\n     * Method to delete an index from the Elasticsearch database if it exists.\n     * @returns A promise that resolves when the deletion is complete.\n     */\n    deleteIfExists(): Promise<void>;\n}\nexport {};\n//# sourceMappingURL=elasticsearch.d.ts.map"],"mappings":";;;;;;;;;;AAImE;AAK9C;AAIC,KAJjBK,gBAAAA,GAQKE,MAAmB;AAU7B;AAQA;AAUA;KAhCKD,iBAAAA,GAiCgBN,SAAAA,GAAAA,aAAAA,GAAAA,QAAAA;;;AAG0B;AAC9C,UAjCSO,mBAAAA,CAqCQ;EAwBGK,SAAAA,MAAAA,CAAAA,EA5DCP,gBA4DkB;EACxBM,SAAAA,UAAAA,CAAAA,EA5DUL,iBA4DVK;EAWYV,SAAAA,CAAAA,CAAAA,EAAAA,MAAAA;EAA2BS,SAAAA,cAAAA,CAAAA,EAAAA,MAAAA;EAS3BP,SAAAA,UAAAA,CAAAA,EAAAA,MAAAA;;;;;AAeyDC,UAvFpEI,6BAAAA,CAuFoEJ;EAAoBD,cAAAA,CAAAA,EAAAA,MAAAA;EAARU,YAAAA,CAAAA,EAAAA,MAAAA;EAUxBF,SAAAA,CAAAA,EAAAA,MAAAA;;;;;AAqBkCD,cA9GtFD,uBAAAA,CA8GsFC;EAA4BE,SAAAA,cAAAA,EAAAA,MAAAA;EAARC,SAAAA,YAAAA,EAAAA,MAAAA;EAUhGV,SAAAA,SAAAA,EAAAA,MAAAA;EAAwBF,WAAAA,CAAAA,MAAAA,CAAAA,EApH9BO,6BAoH8BP;;;;;;AAS6CW,UAvHnFF,iBAAAA,CAuHmFE;EAARC,SAAAA,MAAAA,EAtHvEb,MAsHuEa;EAOtEA,SAAAA,SAAAA,CAAAA,EAAAA,MAAAA;EAKAA,SAAAA,mBAAAA,CAAAA,EAhIaN,mBAgIbM;EAlG2BX,SAAAA,QAAAA,CAAAA,EA7BzBO,uBA6ByBP;AAAW;;;;KAxBvDS,aAAAA;;;;;;;;;;;;;;;;;;;;;;;;cAwBgBC,mBAAAA,SAA4BV,WAAAA;cACjCS;;;;;;;;;;;0BAWYV,2BAA2BS;;;;;;;;;0BAS3BP;;MAEpBU;;;;;;;;;;6CAUuCV;;MAEvCU;uDACiDF,4BAA4BP,YAAYS,QAAQV;;;;;;;;;;uEAUhCQ,gBAAgBE,SAASV;;;;;;;;;MAS1FU;;;;;;;;;;;;8EAYwEZ,2BAA2BS,oBAAoBG,QAAQD;;;;;;;;;;6BAUxGT,wBAAwBF,+BAA+BS,oBAAoBG,QAAQD;;;;;;;;;uCASzEX,+BAA+BS,oBAAoBG,QAAQD;;;;;;;oBAO9EC;;;;;oBAKAA"}