sellAI
scatter_plot

Vectorize

Store the 'meaning' of your text as vectors, then find the closest matches — the memory layer behind RAG and semantic search.

1,536Max dimensions
10MVectors per index
3Distance metrics
lightbulb

What is Vectorize?

Vectorize is a vector database: it stores embeddings (向量, lists of numbers that capture the meaning of text, images or audio) and quickly finds the ones most similar to a query. That's how computers search by meaning instead of exact keywords.

An AI model first turns each piece of text into a vector. Similar meanings end up as nearby vectors. Vectorize stores millions of them and, given a new vector, returns the closest matches in milliseconds.

map

Think of it like a map of meaning

Picture every sentence as a pin on a giant map, where related ideas sit close together. To answer a question, you drop a new pin and look at its nearest neighbors. Vectorize is that map, and it finds the nearest pins instantly.

help

Why use it?

Keyword search misses anything phrased differently. Vectorize understands meaning, which unlocks smarter search and lets you give an AI model real, up-to-date knowledge.

psychology

Search by meaning

Find 'how to reset my password' even when the document says 'recover account access'.

auto_stories

Powers RAG

RAG (Retrieval-Augmented Generation, 檢索增強生成) feeds an AI the most relevant facts so answers are accurate, not made up.

public

Globally fast

Runs on Cloudflare's network and pairs natively with Workers, so queries return quickly worldwide.

tune

No servers to run

Create an index with one command — no clusters to size, patch or babysit.

target

When should you use it?

smart_toy

Chat over your docs

Build a bot that answers from your own manuals, wiki or support articles using RAG.

search

Smart site search

Let users search by what they mean, returning relevant results even with different wording.

recommend

Recommendations

Suggest similar products, articles or songs by finding nearby vectors.

filter_alt

Classify & dedupe

Group similar items, flag duplicates, or spot anomalies that stand far apart.

rocket_launch

How do you start?

  1. Create an index

    An index holds vectors of one fixed size. Match the dimensions to your embedding model (here, 768) and pick a distance metric like cosine.

    bash
    wrangler vectorize create my-index --dimensions=768 --metric=cosine
  2. Add the binding

    Wire the index into your Worker via wrangler.jsonc so env.VECTORIZE is available in code.

    jsonc
    {
      "name": "my-search-worker",
      "main": "src/index.js",
      "compatibility_date": "2025-06-01",
      "vectorize": [
        { "binding": "VECTORIZE", "index_name": "my-index" }
      ]
    }
  3. Insert & query vectors

    Store vectors with insert(), then query() with a new vector to get the closest matches. Real apps usually generate the numbers with Workers AI embeddings.

    js
    export default {
      async fetch(request, env) {
        // 1) Store a few vectors with metadata
        await env.VECTORIZE.insert([
          { id: "1", values: [0.1, 0.2, 0.3], metadata: { text: "hello" } },
          { id: "2", values: [0.9, 0.8, 0.7], metadata: { text: "world" } }
        ]);
    
        // 2) Find the 3 closest matches to a query vector
        const matches = await env.VECTORIZE.query(
          [0.1, 0.2, 0.25],
          { topK: 3, returnMetadata: true }
        );
        return Response.json(matches);
      }
    };
  4. Deploy

    Publish your Worker and start querying from anywhere.

    bash
    wrangler deploy
school

Key concepts

data_array

Embedding 向量

A list of numbers an AI model produces to represent the meaning of some text, image or audio.

straighten

Dimensions 維度

How long each vector is. It must match your model — Vectorize supports up to 1,536.

social_distance

Distance metric 距離度量

The rule for measuring 'closeness': cosine, euclidean or dot-product. Pick the one your model recommends.

filter_list

Metadata filtering

Attach tags (like category or date) to each vector and filter results by them during a query.

auto_stories

RAG 檢索增強生成

Retrieve the most relevant chunks from Vectorize, then hand them to an AI model to write a grounded answer.

tips_and_updates

Tips & limits

link

Pair it with Workers AI

Use a Workers AI embedding model to turn text into vectors, store them in Vectorize, and have an LLM answer from the matches. That trio is a complete RAG pipeline.

  • Each index holds up to 10,000,000 vectors, with up to 1,536 dimensions each.
  • A query returns up to 100 results (or up to 50 when also returning values/metadata).
  • Each vector can carry up to 10 KiB of metadata.
  • Free plan allows up to 100 indexes; the Workers Paid plan allows far more.