langchain.js
    Preparing search index...

    Example usage:

    // Initialize the vector store
    const vectorStore = new AzionVectorStore(embeddings, {
    dbName: "mydb",
    tableName: "documents"
    });

    // Setup database with hybrid search and metadata columns
    await vectorStore.setupDatabase({
    columns: ["topic", "language"],
    mode: "hybrid"
    });


    // OR: Initialize using the static create method
    const vectorStore = await AzionVectorStore.initialize(embeddings, {
    dbName: "mydb",
    tableName: "documents"
    }, {
    columns: ["topic", "language"],
    mode: "hybrid"
    });

    By default, the columns are not expanded, meaning that the metadata is stored in a single column:

    // Setup database with hybrid search and metadata columns
    await vectorStore.setupDatabase({
    columns: ["*"],
    mode: "hybrid"
    });

    // Add documents to the vector store
    await vectorStore.addDocuments([
    new Document({
    pageContent: "Australia is known for its unique wildlife",
    metadata: { topic: "nature", language: "en" }
    })
    ]);

    // Perform similarity search
    const results = await vectorStore.similaritySearch(
    "coral reefs in Australia",
    2, // Return top 2 results
    { filter: [{ operator: "=", column: "topic", string: "biology" }] } // Optional AzionFilter
    );

    // Perform full text search
    const ftResults = await vectorStore.fullTextSearch(
    "Sydney Opera House",
    1, // Return top result
    { filter: [{ operator: "=", column: "language", string: "en" }] } // Optional AzionFilter
    );

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    dbName: string

    Name of the database to use

    expandedMetadata: boolean

    Whether the metadata is contained in a single column or multiple columns

    FilterType: AzionFilter[]

    Type declaration for filter type

    tableName: string

    Name of the main table to store vectors and documents

    Methods

    • Returns string

    • Adds documents to the vector store.

      Parameters

      • documents: Document[]

        The documents to add.

      Returns Promise<void>

      A promise that resolves when the documents have been added.

    • Adds vectors to the vector store.

      Parameters

      • vectors: number[][]

        The vectors to add.

      • documents: Document[]

        The documents associated with the vectors.

      Returns Promise<void>

      A promise that resolves with the IDs of the added vectors when the vectors have been added.

    • Performs a full-text search on the vector store and returns the top 'k' similar documents.

      Parameters

      • query: string

        The query string to search for

      • options: FullTextSearchOptions

        The options for the full-text search, including: - kfts: The number of full-text search results to return - filter: Optional filters to apply to narrow down the search results - metadataItems: Optional metadata fields to include in the results

      Returns Promise<[Document, number][]>

      A promise that resolves with the full-text search results when the search is complete.

    • Performs a hybrid search on the vector store and returns the top 'k' similar documents.

      Parameters

      • query: string

        The query string to search for

      • hybridSearchOptions: HybridSearchOptions

      Returns Promise<[Document, number][]>

      A promise that resolves with the hybrid search results when the search is complete.

    • Performs a similarity search on the vector store and returns the top 'k' similar documents.

      Parameters

      • query: string

        The query string.

      • options: SimilaritySearchOptions

        The options for the similarity search, including: - kvector: The number of vector search results to return - filter: Optional filters to apply to the search - metadataItems: Optional metadata fields to include in results

      Returns Promise<[Document, number][]>

      A promise that resolves with the similarity search results when the search is complete.

    • Converts a query to a FTS query.

      Parameters

      • query: string

        The user query

      Returns string

      The converted FTS query

    • Deletes documents from the vector store.

      Parameters

      • ids: string[]

        The IDs of the documents to delete.

      Returns Promise<void>

      A promise that resolves when the documents have been deleted.

    • Sets up the database and tables.

      Parameters

      • setupOptions: AzionSetupOptions

        The setup options:

        • columns: string[] - The metadata columns to add to the table
        • mode: "vector" | "hybrid" - The mode to use for the table. "vector" for vector search only, "hybrid" for vector and full-text search

      Returns Promise<void>

      A promise that resolves when the database and tables have been set up.

    • Performs a similarity search on the vector store and returns the top 'similarityK' similar documents.

      Parameters

      • vector: number[]

        The vector to search for.

      • k: number

        The number of documents to return.

      • Optionalfilter: AzionFilter[]

        Optional filters to apply to the search.

      • OptionalmetadataItems: string[]

        Optional metadata items to include in the search.

      Returns Promise<[Document, number][]>

      A promise that resolves with the similarity search results when the search is complete.

    • Creates a new vector store instance and sets up the database.

      Parameters

      • embeddings: EmbeddingsInterface

        The embeddings interface to use for vectorizing documents

      • args: AzionVectorStoreArgs

        Configuration options:

        Interface for the arguments required to initialize an Azion library.

        • dbName: string
        • OptionalexpandedMetadata?: boolean
        • Optionalfilter?: AzionFilter[]
        • tableName: string
      • setupOptions: AzionSetupOptions

        Database setup options:

        • columns

          Additional columns to create in the table beyond the required ones. If expandedMetadata is true, this is required.

        • mode

          The search mode to enable: - "vector": Only vector similarity search capabilities - "hybrid": Both vector and full-text search capabilities

      Returns Promise<AzionVectorStore>

      A promise that resolves with the configured vector store instance