Cloudflare - v1.3.0
    Preparing search index...

    Class VectorizeService<E>

    Similarity-search capability, backed by Vectorize.

    Embeddings come from AIService.embed — this capability stores and searches them, and has no opinion about how they were produced. Writes are applied asynchronously, so a mutation id comes back rather than the applied state.

    Bayu Dwiyan Satria

    1.0.0

    1.0.0

    Type Parameters

    Implements

    • VectorIndex<E>
    Index
    • Stores or replaces a vector.

      Parameters

      • env: E

        The Worker environment.

      • id: string

        Id to store the vector under — reuse the source record's id.

      • vector: number[]

        The embedding.

      • metadata: Record<string, VectorizeVectorMetadata> = {}

        Metadata returned with future matches.

      Returns Promise<string>

      The mutation id.

    • Reports whether the index is bound to this Worker.

      Parameters

      • env: E

        The Worker environment.

      Returns boolean

      true when the binding is present.

    • Removes vectors by id.

      Parameters

      • env: E

        The Worker environment.

      • ids: string[]

        The vector ids to remove.

      Returns Promise<string>

      The mutation id.

    • Finds the vectors closest to a query embedding.

      Parameters

      • env: E

        The Worker environment.

      • vector: number[]

        The query embedding.

      • OptionaltopK: number

        How many matches to return. Falls back to the configured value.

      Returns Promise<VectorMatch[]>

      The matches, ordered by similarity.

    • Finds the vectors closest to one already in the index.

      Saves re-embedding a stored record just to search with it.

      Parameters

      • env: E

        The Worker environment.

      • id: string

        The stored vector's id.

      Returns Promise<VectorMatch[]>

      The matches, ordered by similarity.