Class that provides a wrapper around the OpenSearch service for vector search. It provides methods for adding documents and vectors to the OpenSearch index, searching for similar vectors, and managing the OpenSearch index.

Hierarchy

Constructors

Properties

FilterType: object
embeddings: Embeddings
lc_kwargs: SerializedFields
lc_namespace: string[] = ...

A path to the module that contains the class, eg. ["langchain", "llms"] Usually should be the same as the entrypoint the class is exported from.

lc_serializable: boolean = false

Accessors

  • get lc_aliases(): undefined | {
        [key: string]: string;
    }
  • A map of aliases for constructor args. Keys are the attribute names, e.g. "foo". Values are the alias that will replace the key in serialization. This is used to eg. make argument names match Python.

    Returns undefined | {
        [key: string]: string;
    }

  • get lc_attributes(): undefined | SerializedFields
  • A map of additional attributes to merge with constructor args. Keys are the attribute names, e.g. "foo". Values are the attribute values, which will be serialized. These attributes need to be accepted by the constructor as arguments.

    Returns undefined | SerializedFields

  • get lc_secrets(): undefined | {
        [key: string]: string;
    }
  • A map of secrets, which will be omitted from serialization. Keys are paths to the secret in constructor args, e.g. "foo.bar.baz". Values are the secret ids, which will be used when deserializing.

    Returns undefined | {
        [key: string]: string;
    }

Methods

  • Method to add documents to the OpenSearch index. It first converts the documents to vectors using the embeddings, then adds the vectors to the index.

    Parameters

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

      The documents to be added to the OpenSearch index.

    Returns Promise<void>

    Promise resolving to void.

  • Method to add vectors to the OpenSearch index. It ensures the index exists, then adds the vectors and associated documents to the index.

    Parameters

    • vectors: number[][]

      The vectors to be added to the OpenSearch index.

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

      The documents associated with the vectors.

    • Optional options: {
          ids?: string[];
      }

      Optional parameter that can contain the IDs for the documents.

      • Optional ids?: string[]

    Returns Promise<void>

    Promise resolving to void.

  • Method to check if the OpenSearch index exists.

    Returns Promise<boolean>

    Promise resolving to a boolean indicating whether the index exists.

  • Method to perform a similarity search on the OpenSearch index using a query vector. It returns the k most similar documents and their scores.

    Parameters

    • query: number[]

      The query vector.

    • k: number

      The number of similar documents to return.

    • Optional filter: object

      Optional filter for the OpenSearch query.

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

    Promise resolving to an array of tuples, each containing a Document and its score.

  • Static method to create a new OpenSearchVectorStore from an array of texts, their metadata, embeddings, and OpenSearch client arguments.

    Parameters

    • texts: string[]

      The texts to be converted into documents and added to the OpenSearch index.

    • metadatas: object | object[]

      The metadata associated with the texts. Can be an array of objects or a single object.

    • embeddings: Embeddings

      The embeddings used to convert the texts into vectors.

    • args: OpenSearchClientArgs

      The OpenSearch client arguments.

    Returns Promise<OpenSearchVectorStore>

    Promise resolving to a new instance of OpenSearchVectorStore.

  • The name of the serializable. Override to provide an alias or to preserve the serialized module name in minified environments.

    Implemented as a static method to support loading logic.

    Returns string

Generated using TypeDoc