Vectorize
Store the 'meaning' of your text as vectors, then find the closest matches — the memory layer behind RAG and semantic search.
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.
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.
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.
Search by meaning
Find 'how to reset my password' even when the document says 'recover account access'.
Powers RAG
RAG (Retrieval-Augmented Generation, 檢索增強生成) feeds an AI the most relevant facts so answers are accurate, not made up.
Globally fast
Runs on Cloudflare's network and pairs natively with Workers, so queries return quickly worldwide.
No servers to run
Create an index with one command — no clusters to size, patch or babysit.
When should you use it?
Chat over your docs
Build a bot that answers from your own manuals, wiki or support articles using RAG.
Smart site search
Let users search by what they mean, returning relevant results even with different wording.
Recommendations
Suggest similar products, articles or songs by finding nearby vectors.
Classify & dedupe
Group similar items, flag duplicates, or spot anomalies that stand far apart.
How do you start?
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.
wrangler vectorize create my-index --dimensions=768 --metric=cosineAdd the binding
Wire the index into your Worker via wrangler.jsonc so env.VECTORIZE is available in code.
{ "name": "my-search-worker", "main": "src/index.js", "compatibility_date": "2025-06-01", "vectorize": [ { "binding": "VECTORIZE", "index_name": "my-index" } ] }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.
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); } };Deploy
Publish your Worker and start querying from anywhere.
wrangler deploy
Key concepts
Embedding 向量
A list of numbers an AI model produces to represent the meaning of some text, image or audio.
Dimensions 維度
How long each vector is. It must match your model — Vectorize supports up to 1,536.
Distance metric 距離度量
The rule for measuring 'closeness': cosine, euclidean or dot-product. Pick the one your model recommends.
Metadata filtering
Attach tags (like category or date) to each vector and filter results by them during a query.
RAG 檢索增強生成
Retrieve the most relevant chunks from Vectorize, then hand them to an AI model to write a grounded answer.
Tips & limits
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.
Related products
menu_bookOfficial docsopen_in_new