argia-migrator - v0.3.0
    Preparing search index...

    Interface VectorStore<M, F>

    The three things Argia needs from a vector database. Write the adapter for yours; Argia ships none.

    Both writes must be conditional on version, atomically, or two writers can leave the two stores holding different copies of one document. In Postgres that is INSERT ... ON CONFLICT (id) DO UPDATE ... WHERE stored.version <= excluded.version, with deletes kept as tombstone rows the same condition applies to and queries skip.

    F is the filter your query accepts. Argia passes it through untouched, so when the two stores are different databases, give both adapters one filter shape and translate it inside each.

    interface VectorStore<M, F = unknown> {
        delete(deletions: Deletion[]): Promise<void>;
        query(
            vector: number[],
            k: number,
            filter: F | undefined,
        ): Promise<Hit<M>[]>;
        upsert(points: Point<M>[]): Promise<void>;
        versions?(ids: string[]): Promise<(StoredVersion | null)[]>;
    }

    Type Parameters

    • M
    • F = unknown
    Index
    • Remove when the stored version is not higher, and remember the deletion so a later upsert at or below its version is ignored. Ids that do not exist are not an error.

      Parameters

      Returns Promise<void>

    • The k nearest points to vector, best first. filter is undefined when the caller gave none.

      Parameters

      • vector: number[]
      • k: number
      • filter: F | undefined

      Returns Promise<Hit<M>[]>

    • Insert, or replace when the stored version (or tombstone) is not higher. An equal version replaces, so retrying a failed write is safe.

      Parameters

      Returns Promise<void>

    • Optional; needed only by Migration.diff. One entry per id, in the same order: the stored version and whether it is a tombstone, or null for an id the store has never seen (or whose tombstone was purged).

      Parameters

      • ids: string[]

      Returns Promise<(StoredVersion | null)[]>