Skip to main content
Search articles by meaning, then add BM25 keywords so exact tokens like an error code also match. Each article is split into overlapping chunks, embedded, and searched two ways: dense only, and dense plus keywords fused by rank.

Jump to the manifest

semantic-search.namespace.yaml: apply it with one API call, then read the walkthrough below to change it.

At a glance

How the pieces connect

Buckets hold what you upload, collections turn it into searchable documents, and retrievers answer queries over the collections.

Deploy it

1

Get the manifest

2

Validate it

Validate runs every check apply runs and creates nothing. Fix each entry in errors, then run it again.
3

Apply it

Apply creates every resource in one call. wait_for_seed=true also waits until the sample objects are processed, so the first query below has documents to return.
The response lists each resource with its outcome in resources. Apply refuses a resource that already exists and rolls the whole apply back, so to apply the file again over this namespace add ?mode=create_missing, which creates only what is missing.

Run the first query

Look up the namespace id by name, then run kb-search. Check status and warnings along with documents: a run that times out still answers 200, with status degraded.

Add your own data

Each object you add to a bucket is processed by every collection that reads it. This adds one object to knowledge-base. NAMESPACE_ID is the id from the namespace lookup above.
The object is PENDING until processing finishes, then COMPLETED or FAILED. Buckets and objects covers object states, retries and duplicates.

Retrievers

Ask a question in plain words and get back the article chunks closest in meaning, best first. Stages: feature_search Searches: kb-chunks

kb-hybrid

The same question searched two ways, by meaning and by BM25 keywords, fused by rank, so exact tokens such as an error code or a header name also count. Stages: feature_search Searches: kb-chunks

Collections

Each collection runs one extractor over a bucket, or over another collection’s documents.
text_extractor@v1 over bucket knowledge-base: each article split into chunks of 3 sentences, overlapping by 1, and each chunk embedded. Feeds kb-search and kb-hybrid.Reads bucket knowledge-base with text_extractor v1.Inputs: text ← contentCopied onto each document: title, category, tags

The manifest

Every resource above comes from this file. Change it and apply it again with ?mode=upsert to update what exists. Manifests documents each field.
semantic-search.namespace.yaml

Hand it to an agent

Paste this prompt into Claude Code, Cursor or another coding agent. To give the agent this whole page instead, use Copy page in the menu at the top of the page, or point it at the page’s Markdown at https://mixpeek.com/docs/templates/semantic-search.md.
Prompt

How it works

Each article you upload goes through three steps before you can search it.
  1. Chunking. text_extractor reads the bucket’s content property (the input_mappings line text: content) and splits it with split_by: sentences, chunk_size: 3 and chunk_overlap: 1. Each chunk holds 3 sentences, and its last sentence opens the next chunk, so the two sentences on either side of a boundary also appear together in one chunk.
  2. Embedding. Each chunk becomes one document with its text in text and a 1024-dimension vector from multilingual-e5-large-instruct, the extractor’s default text model. The model covers more than 100 languages, so a question in one language can match an article written in another.
  3. Passthrough. field_passthrough copies title, category and tags from the object onto every chunk, at the same paths. You filter on category without joining back to the bucket.
The namespace declares two payload indexes. The text index on text is what the BM25 search in kb-hybrid matches against. The keyword index on category serves the filters further down this page. Both retrievers name the feature as mixpeek://text_extractor@v1. The text extractor has one vector index, so the URI needs no index name after the version. Each change below is an edit to one block of the manifest. Apply the file again with ?mode=upsert to patch what exists. kb-search embeds your query and compares it with every chunk by meaning. It suits questions phrased the way a user asks them, such as the first query above, which the rate-limits article answers in other words. Dense vectors are weaker on exact tokens: an error code, a header name, a product SKU. kb-hybrid runs a second search with lexical: true, which matches the query’s words against the text index with BM25 and searches no vector. fusion: rrf merges the two ranked lists by position, so the gap between cosine scores and BM25 scores does not matter. Run the same token query against both retrievers and compare the order of documents:
cURL
A search with lexical: true replaces the dense search for that entry. Hybrid retrieval needs both entries in searches, as kb-hybrid has them. A single lexical: true entry is keyword search alone.
To make one side lead, switch fusion to dbsf and give each search a weight. DBSF scales each search’s scores to 0 to 1 before it adds them, so the weights act on comparable numbers. Under rrf a weight moves ranks only slightly.
kb-hybrid stages, keywords weighted higher

Filter by metadata

Every chunk carries its article’s category. Filter on it per request or in the retriever.
Send filters in the execute body. The retriever ANDs it with any filter its stages already have, so one retriever serves every category.
cURL
A filtered field needs a payload index, which is why the namespace declares category as keyword. To filter on another field, such as title, add it to payload_indexes the same way.

Rerank the top results

A cross-encoder reads the query and each chunk together and scores the pair. It ranks more precisely than vector distance and costs more time per document, so run it on the few chunks the search returned. Add a rerank stage after the search:
kb-hybrid stages, with a rerank stage
  • document_field: text points the reranker at the chunk text. The stage’s default is content, a field these chunks do not have, and the stage leaves out every document without the field.
  • max_candidates caps how many incoming documents the reranker scores. At 4 CPU, 10 documents take about 8 seconds with BAAI__bge_reranker_v2_m3, so raise it with care.
  • The reranker writes its score to scores.rerank on each document and keeps the best top_k.
If the deployment does not serve the named reranker, saving the retriever returns a 422 whose details.served_alternatives lists the rerankers it does serve. Rerank covers the other parameters.

Change the chunking

Chunk size trades precision for context. Small chunks point at the exact sentence and lose what surrounds it; large chunks keep context and blur the match. chunk_size and chunk_overlap count in the unit split_by names. For Markdown sources, one chunk per heading section, with the heading path on each chunk in heading_path:
kb-chunks feature_extractor.parameters
Chunking runs at ingest. Existing chunks keep their old boundaries until you process the objects again.

Next steps

Feature Search

Every search, fusion and grouping option for the stage both retrievers use.

Text extractor

Chunking, HTML pages, YouTube captions and structured extraction.

Classify documents

Tag each article against a taxonomy of reference categories.

Discover topics

Cluster chunk embeddings to find topic groups you did not define.