docgrep
Local search over your own documents: ranked, verbatim passages with the file and page or heading they come from. No cloud, no telemetry, no generated answers.
- Maintainer
- Viktor Mikhalkin
- License
- AGPL-3.0-or-later
- Published
Problem
A personal library of books, papers and notes is easy to collect and hard to search. File search finds names, not passages. Full-text search misses a passage when the query uses other words. Chat assistants that answer from documents paraphrase them, and it is hard to check where an answer came from.
docgrep returns the passages themselves, verbatim, ranked by relevance, with the file and the page or heading path of each one.
Scope
- Indexes TXT, Markdown, PDF, EPUB, DOCX and DjVu files in one or more folders.
- Finds scanned PDF and DjVu files without a text layer and makes them searchable with OCR. The original files are never changed.
- Searches from the command line, over a local HTTP API, and as read-only tools for MCP clients such as Claude Code.
- Runs entirely on the user’s machine. A GPU is optional.
It does not generate answers or summaries, and it sends nothing to the network after the models are downloaded.
Architecture
- Layered Python package: API, use cases, domain and adapters. Each important design choice is recorded in an architecture decision record.
- Two-stage hybrid search. The first stage fuses dense vectors (
bge-m3) with BM25-weighted sparse vectors by reciprocal rank fusion. The second stage reranks the candidates with a cross-encoder (bge-reranker-v2-m3). - Qdrant stores the vectors: an embedded local mode for small collections, a Qdrant server for large ones. A SQLite manifest tracks sources and runs.
- Incremental updates compare the corpus with the index by content hash, so moved, renamed and copied files are not embedded again.
Current result
Version 1.26.0. Indexing, updates with a plan preview, cancel and resume, OCR of scans, filtered search, passage context, source browsing, the HTTP API, the MCP server and automatic sync of the index with the corpus are implemented.
docgrep replaces an earlier retrieval prototype for an Obsidian vault, which is now archived.
Verification
- Continuous integration runs
ruff,mypy --strictand the test suite against a Qdrant server on every change. docgrep evalmeasures retrieval quality on a file of known query–passage pairs: the rank of the expected passage at each stage, recall@k and MRR. Changes to retrieval are decided with these numbers.
Reproducibility
Python 3.12, uv and git are required.
git clone https://github.com/metronforge/docgrep.git
cd docgrep
uv sync --extra cpu
uv run docgrep roots add library "$HOME/Documents"
uv run docgrep index
uv run docgrep search "a sentence you remember"
The README gives the full setup, including GPU and Qdrant server options.
Limitations
- The first run downloads several gigabytes of models. A large library can take hours to index on a CPU.
- Local mode suits collections of up to about 20,000 passages and lets only one process open the index; larger libraries need a Qdrant server.
- DOC, RTF and ODT files are not supported. DOCX and EPUB results have no page numbers.
- Retrieval quality depends on the models and on the text layer of the source files. No results on a public benchmark are published.