Hearth documentation

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

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

Select Save after changing a setting.

Search by meaning

  1. 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: 1g
    
  2. Tell Hearth where it is (both settings, or neither):

    QDRANT_URL: http://hearth-qdrant:6333
    QDRANT_API_KEY_FILE: /run/hearth/qdrant-key
    
  3. Set up LiteLLM (Copilot) with at least one embedding model.

  4. 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: