Search and text recognition
Hearth keeps one content index of the text of everything each person can read: their files, what is shared with them, spaces' libraries and pages, Notes, tables, mail, calendar events, tasks and contacts. The header's search and the Copilot both use it.
The index has two finders. Word search runs in Postgres and needs nothing extra. Search by meaning finds the same thing said in other words; it needs an embedding model through LiteLLM and a Qdrant vector store. Text recognition reads scans and pictures so their words can be found too.
What is indexed, and what is not
- Word, Excel, PowerPoint, OpenDocument, PDF, HTML, text, Markdown and code files are read on the server. PDFs are read page by page. Office files over 40 MB are not read, and of a larger plain-text file only the first 8 MB.
- Folders encrypted at rest are indexed: the text is in Hearth's database, where it is protected like the rest of the metadata.
- Folders encrypted end to end are never indexed.
- External storage is not indexed.
- Drafts in spaces and changes waiting for approval are not indexed.
- Subscribed calendars are not indexed. Events marked private are found by their owner only.
Permissions are checked at every search, against what the person may read at that moment. A share that is withdrawn stops matching at once.
Changes are indexed a few seconds after a save. Files that existed
before the index was turned on are read by a backfill that pauses while
the server is busy and goes faster at night (JOBS_NIGHT_HOURS).
Administration, Search index
- Search contents: the index on or off.
- Search by meaning: Off, or an embedding model LiteLLM offers. The number of parts to embed is shown before you choose, so you can judge the cost.
- Least similarity: below this, a part is not a match by meaning, so a question about something nobody holds finds nothing. Hearth fills it in for models it has calibrated. Word matches are never cut off.
- Backlog by day and Backlog at night: how fast the backfill goes.
- Text recognition, with Recognition by day and Recognition at night: the pace of reading scans and pictures.
- Personal ranking: among results that match equally well, what each person works with comes first. Only that person's own searches read their ranking. Turning it off deletes it for everyone.
- Counts: what is indexed, with meaning, queued and failed.
- Not indexed: the documents that could not be read, with the reason, and Read again for one.
- Read every file again: reads every file again. Unchanged files keep their text, so it is cheap where little changed.
Select Save after changing a setting.
Search by meaning
Run Qdrant beside Hearth, with an API key:
hearth-qdrant: image: qdrant/qdrant:v1.20.2 restart: unless-stopped command: - bash - -c - export QDRANT__SERVICE__API_KEY="$$(cat /run/secrets/qdrant-key)" && exec ./entrypoint.sh environment: QDRANT__TELEMETRY_DISABLED: "true" volumes: - ./data/qdrant:/qdrant/storage - ./secrets/qdrant-key:/run/secrets/qdrant-key:ro mem_limit: 1gTell Hearth where it is (both settings, or neither):
QDRANT_URL: http://hearth-qdrant:6333 QDRANT_API_KEY_FILE: /run/hearth/qdrant-keySet up LiteLLM (Copilot) with at least one embedding model.
In Administration, Search index, choose the model under Search by meaning and select Save.
Qdrant's data can be rebuilt from Hearth's database, so it need not be in the backup. After a change of model, everything is embedded again in the background.
Text recognition
Text recognition (OCR) reads the words in scans and pictures. The image ships the helper and its models:
OCR_HELPER: /usr/local/bin/hearth-ocr
OCR_MODELS_DIR: /usr/local/share/hearth-ocr/models
It reads English, with columns in reading order. Two models come with it:
a small one, and a tiny one that is faster and less accurate. When the
container is busy (memory at OCR_TINY_MEMORY_PERCENT or processors at
OCR_TINY_CPU_PERCENT of its limits), pages are read with the tiny
model, and read again with the small one later when there is room.
In the background, pages are read one at a time at the lowest processor priority, a few a minute by day and faster at night, and never while the server is busy. The words are added to the index; the file itself is not changed.
Recognise text in the PDF workspace is the other use: it writes a text layer into a PDF when someone asks, at once. These settings limit it:
| Setting | Default | Meaning |
|---|---|---|
OCR_WORKERS |
2 | readings at once for Recognise text (the background has one of its own) |
OCR_THREADS |
2 | cores one reading may use |
OCR_TIMEOUT_SECONDS |
300 | one reading's time limit |
OCR_MEMORY_MB |
2048 | one reading's memory limit; a page takes about 1 GB with the small model, 0.5 GB with the tiny one |
Without OCR_HELPER, scans are not read and Recognise text is not
offered.
Commands
docker compose exec -T hearth /hearth index show
shows the settings, the counts and the queue.
docker compose exec -T hearth /hearth index set --on --embed-model NAME
changes the settings from the command line. A flag you leave out keeps its value:
--onor--off: the index on or off;--embed-model NAME(as LiteLLM names it), with--min-score Xto set the least similarity yourself, or--no-embedfor word search only;--rate-day Nand--rate-night N: the backlog's pace.