← Otto Developer Guideotto-search

User guide: Files
Specs: Search Language

otto-search is Otto’s file search, in components/otto-search/: one query language over the desktop’s file index, so the same words find the same files in Files, in Settings and on the command line. It turns a query into SPARQL, asks LocalSearch (TinySPARQL) over D-Bus, and checks what comes back against the disk. It sits in the service layer of architecture.toml: no toolkit and no Wayland, so command-line tools and daemons can link it. It is a library plus the otto-search command, and runs no service of its own.

Files and the otto-search command parse a query, plan it and run find, which pages SPARQL results from LocalSearch and checks each row on disk; Settings reads the indexer’s status and asks it to reindex

The pipeline, the SPARQL it writes, ranking, threading in Files and what happens when the index cannot answer are described in File Search. This page is the map of the crate.

Modules

ModuleWhat it does
query.rsparse: text into terms. It never fails: a token that does not parse stays a plain word and carries an Issue the caller can show
plan.rsPlan::new resolves a query against a Scope (where to look) and a Clock (what today means). The plan then renders SPARQL for the index, or admits checks a file found some other way
find.rsfind: runs a plan to a ranked, capped list of files that are really there. It pages past rows the index remembers but the disk no longer has, stats each row, checks it again against the plan, and reports progress page by page
index.rsThe LocalSearch wire: search, counts, status and reindex, plus file: URL conversion
dates.rsCalendar arithmetic for modified:, without a date crate
main.rsThe otto-search command

How it runs

Every call into the index is blocking: it builds a current-thread tokio runtime for one round trip on the caller’s thread, so callers run it off any UI thread. It talks to these D-Bus objects on the session bus:

The index is asked for paths and, for full-text queries, snippets. Size, modification time and kind are read from the filesystem, because the index always lags the disk a little.

It depends on otto-foundations for name scoring (matching, the scorer the launcher and the toolkit’s lists also use) and for the index’s file: URLs, plus zbus, tokio and libc.

Going deeper