← All posts

Vector Search, Step by Step: Your First Vector Bucket and Its Indexes

9 min read SeaweedFS Team AI & Machine Learning

Ordinary search matches words. Search for “sweet with a little kick” and a keyword engine looks for those exact words. Vector search matches meaning. It can find chili chocolate truffles even though no recipe contains that phrase.

This guide starts with six recipes and a few commands. You’ll store them in a SeaweedFS vector bucket, search them, and filter them. Then you’ll see what indexes do when six recipes become six million.

The idea in one minute

An embedding (or vector) is a list of numbers that describes something. An embedding model, such as one from OpenAI, Cohere, or an open-source library, reads text or an image and returns a few hundred to a few thousand numbers. Things with similar meaning get similar numbers.

Vector search then asks: which stored vectors are closest to my question’s vector?

To make that visible, this guide skips the model and uses hand-made vectors with only three numbers: how sweet, how spicy, and how savory each dish is.

Recipe Sweet Spicy Savory Diet
Mango sticky rice 0.9 0.1 0.2 vegan
Chocolate lava cake 1.0 0.0 0.1 vegetarian
Chili chocolate truffles 0.8 0.6 0.0 vegan
Tofu green curry 0.2 0.9 0.6 vegan
Spicy beef tacos 0.1 0.8 0.9 meat
Mushroom risotto 0.1 0.0 1.0 vegetarian

The Diet column is metadata: a plain label stored next to the vector. You’ll use it to filter.

Three words to know

  • Vector bucket: the top-level container, like an S3 bucket for embeddings.
  • Index: a collection of vectors inside the bucket. Every vector in it has the same length (the dimension) and is compared with the same distance metric. The S3 Vectors API uses “index” for this collection; keep that in mind, because the speed-up indexes later in this guide are something else.
  • Metadata: labels such as diet, language, or customer that you can return with results and use in filters.

1. Start SeaweedFS

Install three binaries from the same SeaweedFS release: weed, the vector engine weed-vector, and the maintenance worker weed-worker. Put all three in one folder on your PATH, such as /usr/local/bin. weed mini starts the vector engine itself and looks for weed-vector next to weed. Also install a recent AWS CLI v2 that includes the aws s3vectors commands. The deployment guide links to the releases.

Create a folder for the demo and a security.toml file with a random secret in it. SeaweedFS’s own programs use this shared secret to trust each other. The maintenance worker you’ll start in step 6 has no S3 credentials, so the secret is how it proves it belongs to your cluster. Then start a single-machine cluster with the vector engine:

mkdir vector-demo && cd vector-demo
printf '[jwt.filer_signing]\nkey = "%s"\n' "$(openssl rand -base64 32)" > security.toml

export AWS_ACCESS_KEY_ID=vector-demo
export AWS_SECRET_ACCESS_KEY=vector-demo-secret
weed mini -dir=./vector-data -ip=127.0.0.1 -ip.bind=127.0.0.1 -vector

weed mini turns the two AWS_ variables into an admin user, so there’s no user file to write. Keep it running. In a second terminal, give the AWS CLI the same credentials:

export AWS_ACCESS_KEY_ID=vector-demo
export AWS_SECRET_ACCESS_KEY=vector-demo-secret
export AWS_DEFAULT_REGION=us-east-1
export VECTOR_ENDPOINT=http://127.0.0.1:8333

SeaweedFS speaks the AWS-compatible S3 Vectors API, so the regular AWS CLI works. You only point it at your own endpoint.

2. Create a bucket and an index

aws --endpoint-url "$VECTOR_ENDPOINT" s3vectors create-vector-bucket \
  --vector-bucket-name kitchen

aws --endpoint-url "$VECTOR_ENDPOINT" s3vectors create-index \
  --vector-bucket-name kitchen --index-name recipes \
  --data-type float32 --dimension 3 --distance-metric cosine

--dimension 3 matches our three flavor numbers. With a real model, use its dimension instead, such as 384, 768, or 1536. Cosine distance compares the direction of two vectors. It suits most text embeddings: a smaller distance means more similar.

3. Add the recipes

aws --endpoint-url "$VECTOR_ENDPOINT" s3vectors put-vectors \
  --vector-bucket-name kitchen --index-name recipes \
  --vectors '[
    {"key":"mango-sticky-rice",       "data":{"float32":[0.9,0.1,0.2]}, "metadata":{"diet":"vegan"}},
    {"key":"chocolate-lava-cake",     "data":{"float32":[1.0,0.0,0.1]}, "metadata":{"diet":"vegetarian"}},
    {"key":"chili-chocolate-truffles","data":{"float32":[0.8,0.6,0.0]}, "metadata":{"diet":"vegan"}},
    {"key":"tofu-green-curry",        "data":{"float32":[0.2,0.9,0.6]}, "metadata":{"diet":"vegan"}},
    {"key":"spicy-beef-tacos",        "data":{"float32":[0.1,0.8,0.9]}, "metadata":{"diet":"meat"}},
    {"key":"mushroom-risotto",        "data":{"float32":[0.1,0.0,1.0]}, "metadata":{"diet":"vegetarian"}}
  ]'

Each vector has a key (its name), the data (the numbers), and optional metadata.

4. Ask a question

“Something sweet with a little kick” is lots of sweet, some spicy, and no savory: [0.9, 0.4, 0.0].

aws --endpoint-url "$VECTOR_ENDPOINT" s3vectors query-vectors \
  --vector-bucket-name kitchen --index-name recipes \
  --query-vector '{"float32":[0.9,0.4,0.0]}' --top-k 3 \
  --return-distance --return-metadata
{
    "vectors": [
        {"distance": 0.02526766,  "key": "chili-chocolate-truffles", "metadata": {"diet": "vegan"}},
        {"distance": 0.06935543,  "key": "mango-sticky-rice",        "metadata": {"diet": "vegan"}},
        {"distance": 0.090723515, "key": "chocolate-lava-cake",      "metadata": {"diet": "vegetarian"}}
    ],
    "distanceMetric": "cosine"
}

The CLI prints each match over several lines; the output above is condensed. The three closest recipes are chili chocolate truffles, mango sticky rice, then chocolate lava cake. The truffles win because they’re the only sweet dish with real heat. Notice that the query never mentions chocolate or chili. That’s vector search.

5. Add a filter

Now ask for something savory, [0.0, 0.2, 1.0], with two results:

aws --endpoint-url "$VECTOR_ENDPOINT" s3vectors query-vectors \
  --vector-bucket-name kitchen --index-name recipes \
  --query-vector '{"float32":[0.0,0.2,1.0]}' --top-k 2 \
  --return-distance --return-metadata

You get mushroom risotto and spicy beef tacos. Your guest is vegan, so add a metadata filter:

aws --endpoint-url "$VECTOR_ENDPOINT" s3vectors query-vectors \
  --vector-bucket-name kitchen --index-name recipes \
  --query-vector '{"float32":[0.0,0.2,1.0]}' --top-k 2 \
  --filter '{"diet":{"$eq":"vegan"}}' \
  --return-distance --return-metadata

Now the answer is tofu green curry, then mango sticky rice. The filter decides which recipes are allowed; similarity decides their order. Most real applications combine the two: search only this customer’s documents, only English articles, or only products in stock.

That’s the whole workflow. A real application follows the same pattern, except that an embedding model produces the numbers.

6. When six rows become six million: indexes

With six recipes, SeaweedFS can compare your question against every row in an instant. With millions of rows, comparing everything on every query gets slow. Indexes are shortcuts that avoid that work. A vector bucket can use two kinds, and each solves a different part of the query.

Filter diet = vegan Question vector [0.0, 0.2, 1.0] Metadata index Jump straight to vegan rows Vector index (ANN) Jump to the nearby neighborhood Top matches Same results, less work
Each part of a query has its own shortcut. Neither one changes the query you send.

Start the maintenance worker

Indexes are built in the background by the Lance maintenance worker, weed-worker. Start it in a third terminal, from the same vector-demo folder, so it reads the same security.toml:

cd vector-demo
weed-worker --admin 127.0.0.1:12535 --masters 127.0.0.1:9333 \
  --namespace http://127.0.0.1:9101

The ports are the weed mini defaults for the Admin UI, master, and Lance catalog. Starting it from the same folder lets it read the secret in security.toml. Without that secret, the worker still connects, but its index jobs fail with 403 Forbidden.

Open the Admin UI at http://127.0.0.1:12535 to follow along.

The vector index: “which rows are close?”

An ANN (approximate nearest neighbor) index groups similar vectors together. A query visits only the nearby groups instead of the whole collection. Think of a library: you walk to the cookbook shelf rather than reading every book.

You don’t build this one by hand. Until it exists, SeaweedFS compares every row, which is fast for small indexes. The Admin UI reports this as Vector index: none (exact scan). Once your data grows, open Maintenance jobs from the vector bucket page and turn on the schedule for Lance Vector Index. The worker then builds the ANN index for any index holding at least 50,000 rows (the default) and keeps it current.

The metadata index: “which rows match my filter?”

This is the new part. Without a metadata index, the filter diet = vegan makes SeaweedFS read each row’s metadata to check the label. A metadata index works like the index at the back of a cookbook: look up “vegan” and go straight to the matching pages.

You add one in the Admin UI:

  1. Open Vector Buckets, select your bucket, and find the index (here, recipes).

  2. Look under Frequently filtered, not indexed. SeaweedFS lists keys your application filters on but hasn’t indexed yet, so you don’t have to guess.

    The Admin UI panel for index recipes: dimension 3, cosine, 6 vectors, vector index none (exact scan). The metadata indexes table is empty. Under Frequently filtered, not indexed, the key diet shows 129 queries per hour, average 8 ms, with an Index button.
    After the vegan query, diet appears as a key worth indexing. On a freshly started engine, the hourly rate is projected from the queries seen so far.
  3. Click Index beside the key, or choose Index a key and type its name, then confirm with Index.

  4. The key moves from Requested to Building within seconds, then to Ready about three minutes later. The worker waits that long on purpose, so writes already in progress are covered before queries rely on the index. Coverage shows how much of the data the index covers.

    The same panel after indexing: the metadata indexes table lists diet, state Ready, coverage 100%, 15 filtered queries per hour, size 0.0 MiB, with a Remove link. Frequently filtered, not indexed now reads: No filtered queries in the last hour on keys without an index.
    diet is Ready at 100% coverage. Run the vegan query again: tofu green curry and mango sticky rice come back with the same distances as before.

Now add one more vegan recipe, a savory lentil shepherd’s pie, and search right away:

aws --endpoint-url "$VECTOR_ENDPOINT" s3vectors put-vectors \
  --vector-bucket-name kitchen --index-name recipes \
  --vectors '[{"key":"lentil-shepherds-pie","data":{"float32":[0.1,0.1,1.0]},"metadata":{"diet":"vegan"}}]'

aws --endpoint-url "$VECTOR_ENDPOINT" s3vectors query-vectors \
  --vector-bucket-name kitchen --index-name recipes \
  --query-vector '{"float32":[0.0,0.2,1.0]}' --top-k 2 \
  --filter '{"diet":{"$eq":"vegan"}}' \
  --return-distance --return-metadata

The pie comes back first, at a distance of about 0.01, ahead of tofu green curry. In the Admin UI, diet coverage drops to 86%: six of the seven recipes are in the index. The new one isn’t yet, but SeaweedFS still finds it.

To fold it in now, open Maintenance jobs and select Lance Metadata Index. Set Unindexed rows to 1 for this tiny demo, click Save Config, then Run Detect + Execute. Coverage returns to 100%, and the query still returns the same two recipes.

Three things make this easy to adopt:

  • Your code doesn’t change. You send the same query with the same filter; it just does less work.
  • New data is never hidden. Rows the index doesn’t cover yet are checked the regular way, as the pie just showed. In production, turn on the schedule for Lance Metadata Index so this happens on its own. With the default Unindexed rows of 50,000, it folds new rows in once that many have built up.
  • Removing it is safe. Remove deletes only the shortcut. Your vectors and metadata stay, and filters on that key keep working.

Which keys should you index?

Index a key your application filters on often, where the filter picks out a small slice of the data. A customer or tenant ID in a shared knowledge base is the classic case. Each query wants maybe 1% of the rows, so skipping the other 99% is a big saving. A key that matches half of your rows saves much less.

This first version speeds up string filters that use $eq and $in, including strings inside metadata arrays. Other filters, such as numeric ranges, still work as before. Each index can have up to eight indexed keys. Keys marked non-filterable when the index was created can’t be filtered on, so they can’t be indexed either.

Where to go next

  • Replace the hand-made numbers with a real embedding model. Use the same model for stored items and questions, and create the index with that model’s dimension.
  • Read the Vector Buckets guide to run in production, and the reference for every request field and operation.
  • Prefer working directly with tables? Try the LanceDB walkthrough. It uses the same Lance storage underneath.
  • At larger scale, Distributed Vector Search (Enterprise) spreads queries across several vector engines while keeping the same API.

Vector search starts with one idea: similar things are close together. Indexes keep that idea fast as your data grows.