Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Search by meaning

The apps always search what’s on the device. The server adds server search over every page a person can read, which the web app and Ask use, and, with an embedding model, search by meaning: pages that say the same thing in other words.

On by default: PostgreSQL full-text search over every block, kept current by a background indexer a couple of seconds after each change.

[search]
enabled = true
text_config = "simple"

text_config is a PostgreSQL text search configuration. simple works for any language without stemming; a language’s own (english, german, french, …) adds stemming for that language (so “gardening” finds “garden”) but suits notes in that language only.

Adding search by meaning

Give the server an embedding model. Any OpenAI-compatible endpoint:

[search.embeddings]
base_url = "http://ollama.example.test:11434/v1"
model = "nomic-embed-text"

Or a vendor’s API, with provider set to openai, google, mistral or openrouter (Anthropic makes no embeddings):

[search.embeddings]
provider = "openai"
model = "text-embedding-3-small"
api_key_file = "/run/secrets/openai"
dimensions = 512
KeyDefault
provider"openai-compatible"Which API it speaks
base_urlunsetNeeded for openai-compatible
modelrequiredThe embedding model’s ID
api_keyunsetNeeded for a vendor
dimensionsunsetAsk for shorter vectors, for models that can make them
batch64Blocks per request
min_similarity0.3How close in meaning (cosine, -1 to 1) a block must be to count. Raise it if searches return unrelated pages; lower it if they miss related ones. Models differ.
idthe modelNames the vector space; see below

Changing the model

Every vector is stored with its model’s ID (with @<dimensions> added when dimensions is set, since a shorter vector is another space). Changing the model, or its dimensions, embeds everything again in the background: when the server starts, it drops the old model’s vectors and indexes, and the indexer re-embeds every page. Until it’s done, search by meaning finds less and full-text search carries on. A sweep every ten minutes picks up any page left without vectors, such as after the embedding model was down for a while.

Any vector size works. Past 2,000 dimensions pgvector can’t build its HNSW index, so searches scan instead, which is fine for a personal notebook and slow for a big team.

What the database holds

The database holds each block’s words (a tsvector) and its embedding, never its text: snippets are made by opening the sealed document when someone searches. But words and embeddings are derived from the text and reveal what it’s about to anyone who can read the database or its backups. To keep them out, turn server search off:

[search]
enabled = false

The apps then search on the device only, and Ask can’t run on the server.

End-to-end encrypted workspaces

The server can’t read them, so it doesn’t index them. Their members’ devices search them, by words and, with an embedding model of their own, by meaning. An owner can let the server’s AI embed pages one request at a time; see End-to-end encryption.