Cloudflare - v1.3.0
    Preparing search index...

    Class VectorizeBinding<E>

    Accessor for the Vectorize index binding (vectorize in wrangler.json).

    const index = new VectorizeBinding() // binding name and default topK from the configuration layer
    const matches = await index.query(ctx.env, embedding)

    Bayu Dwiyan Satria

    1.0.0

    1.0.0

    Type Parameters

    Hierarchy (View Summary)

    Index
    namespace?: string

    Default namespace applied to queries.

    settings: () => VectorizeSettings

    This accessor’s settings, resolved on first read.

    topK?: number

    Default number of matches returned by queries.

    • get name(): string

      The binding name this instance resolves.

      Returns string

      The binding name as declared in wrangler.json.

    • Deletes vectors by id.

      Parameters

      • env: E

        The Worker environment.

      • ids: string[]

        The vector ids to delete.

      Returns Promise<VectorizeAsyncMutation>

      The mutation id — deletes are applied asynchronously.

    • Reads index metadata — dimensions, metric, and vector count.

      Parameters

      • env: E

        The Worker environment.

      Returns Promise<VectorizeIndexInfo>

      Information about the bound index.

    • Fetches vectors by id.

      Parameters

      • env: E

        The Worker environment.

      • ids: string[]

        The vector ids to fetch.

      Returns Promise<VectorizeVector[]>

      The matching vectors, unscored.

    • Inserts vectors, failing when an id already exists.

      Parameters

      • env: E

        The Worker environment.

      • vectors: VectorizeVector[]

        The vectors to insert.

      Returns Promise<VectorizeAsyncMutation>

      The mutation id — writes are applied asynchronously.

    • Checks whether the binding is available on the given environment.

      Use this to degrade gracefully when a binding is optional.

      Parameters

      • env: E

        The Worker environment.

      Returns boolean

      true when the binding is present.

    • Runs a similarity search for the given vector.

      Parameters

      • env: E

        The Worker environment.

      • vector: VectorFloatArray | number[]

        The query vector.

      • options: VectorizeQueryOptions = {}

        Query options — overrides the configured defaults.

      Returns Promise<VectorizeMatches>

      The scored matches, ordered by similarity.

      MissingBindingError When the Vectorize binding is absent.

    • Runs a similarity search for a vector already stored in the index.

      Parameters

      • env: E

        The Worker environment.

      • vectorId: string

        Id of the stored vector to search against.

      • options: VectorizeQueryOptions = {}

        Query options — overrides the configured defaults.

      Returns Promise<VectorizeMatches>

      The scored matches, ordered by similarity.

    • Resolves the binding without throwing.

      Parameters

      • env: E

        The Worker environment.

      Returns Vectorize

      The resolved binding, or null when it is not configured.

    • Inserts vectors, replacing any that already exist.

      Parameters

      • env: E

        The Worker environment.

      • vectors: VectorizeVector[]

        The vectors to upsert.

      Returns Promise<VectorizeAsyncMutation>

      The mutation id — writes are applied asynchronously.

    • Applies the configured defaults to query options that do not set them.

      Parameters

      • options: VectorizeQueryOptions

        The caller-supplied query options.

      Returns VectorizeQueryOptions

      Query options with defaults filled in.