TOOL WIKI · VECTOR & SEARCH

Typesense

Supports application search including keyword and vector-based retrieval.

Download example files Code + setup + checks in a ZIP
Jump to a section 10 sections

EXAMPLE USE CASE

A policy assistant needs relevant records with source ownership; vector similarity alone does not establish who may read them.

Input
A collection schema, policy vector and tenant filter_by expression.
Expected output
The returns policy hit with embeddings excluded from the response.
  • Success check: The nearest authorized record is the returns policy; the unrelated tenant never appears.
  • Try a failure: Check filtered result IDs and an empty authorized partition before showing source text.

Example scope: Actual Typesense service integration; this query tests vector recall rather than a complete hybrid-ranking evaluation.

Official reference · Typesense

WHAT IT ISSearch engine
WHERE IT FITSVector & search
SEE HOW THE SYSTEM FITS TOGETHERSELECT A COMPONENT
ingestindexembed queryscopematchesevidenceSource recordsText + access metadataEmbedding processOne compatible spaceTypesenseSearch engineUser queryAuthenticated scopeFilter + rankRelevant candidatesAgent contextPassages + provenance
  1. Preserve source identifiers, version, tenant, and deletion status.

  2. Use the same embedding model and dimensions for indexed records and queries.

  3. Product-facing search that needs multiple relevance signals. Use a representative query set to tune ranking and evaluate filtering.

  4. Resolve allowed tenants and filters before searching for evidence.

  5. Apply resource permissions and select the evidence that supports this task.

  6. Return source text and identifiers, not a vector distance presented as factual certainty.

    Result or stopping point
Typesense

Product-facing search that needs multiple relevance signals. Use a representative query set to tune ranking and evaluate filtering.

Follow the arrows, then select a component to inspect its responsibility. On mobile, downward arrows connect the next step; bent arrows identify branches and return paths. Select a destination to jump to that component.

When to consider it

  • Product-facing search that needs multiple relevance signals.

A design decision to make

  • Use a representative query set to tune ranking and evaluate filtering.

Prerequisites and setup

  • A TLS-enabled Typesense endpoint and a key limited to a scratch collection.
  • Use a search-only scoped key in browser-facing applications; this ingest example needs a server-side write key.
Shell
python3 -m venv .venv
source .venv/bin/activate
pip install typesense
export TYPESENSE_HOST="YOUR_HOST_WITHOUT_SCHEME"
export TYPESENSE_API_KEY="YOUR_SCOPED_KEY"

Try a small integration

search.py

Python · search.py
import os
import typesense
from typesense.exceptions import ObjectAlreadyExists

client = typesense.Client({"nodes":[{"host":os.environ["TYPESENSE_HOST"],"port":443,"protocol":"https"}],
    "api_key":os.environ["TYPESENSE_API_KEY"],"connection_timeout_seconds":5})
try:
    client.collections.create({"name":"asg-policies","fields":[
        {"name":"tenant","type":"string","facet":True},{"name":"text","type":"string"},
        {"name":"embedding","type":"float[]","num_dim":3}]})
except ObjectAlreadyExists:
    pass
collection = client.collections["asg-policies"]
collection.documents.upsert({"id":"returns-a","tenant":"a","text":"Returns: 30 days","embedding":[1.,0.,0.]})
collection.documents.upsert({"id":"returns-b","tenant":"b","text":"Private policy","embedding":[1.,0.,0.]})
result = collection.documents.search({"q":"*","vector_query":"embedding:([1,0,0], k:5)",
    "filter_by":"tenant:=a","per_page":1,"exclude_fields":"embedding"})
assert result["hits"][0]["document"]["tenant"] == "a"
print(result["hits"])

Run and check the result

Shell
python search.py
  • The nearest authorized record is the returns policy; the unrelated tenant never appears.
  • Change the query vector or tenant filter and inspect the returned IDs, metadata and score ordering.

Common failures

  • Dimension mismatch: align the stored vectors and queries with the same embedding model.
  • An empty result may be a correct filter outcome; do not retry without the tenant constraint.

Production decisions

  • Use embeddings from one named model/version with a fixed dimension and distance metric. The three-value vectors here demonstrate mechanics, not semantic quality.
  • Enforce authenticated tenant/resource filters outside model control. Test filtered recall, deletion, backups, index rebuilds and p95 latency on realistic data.

Keep exploring

Retrieval that can ask a better questionUse PostgreSQL and pgvector for agent memory

Explore the same layer

pgvectorQdrantPineconeWeaviate

Compare candidates on your own workload. This entry describes a product’s role; it is not a claim that products in the category are interchangeable.