Skip to main content

TreeSearch

Structure-aware document retrieval via tree-structured indexing.

No vector embeddings. No chunk splitting. FTS5 keyword matching over document trees.

文档不再被切成无结构的 chunk——每个文件被解析为一棵「标题树」,检索命中 树节点并带路径上下文返回,天然适合代码库、技术文档、笔记库的关键词检索。

安装

pip install treesearchlib            # 轻核心(Markdown / 代码 / JSON / CSV / 纯文本)
pip install "treesearchlib[all]"     # 全能力(格式解析 + CJK 分词 + 词干 + gitignore)

按需加装能力组:

extras 能力 依赖
cjk 中日韩分词 jieba
parsers PDF / DOCX / PPTX / XLSX / HTML pdfplumber, PyMuPDF, python-docx, python-pptx, openpyxl, bs4
image 图像文件(占位索引 + EXIF/XMP 元数据读写回) Pillow, piexif
convert email 等杂项格式 → Markdown markitdown
ast 扩展代码语言(tree-sitter) tree-sitter-languages
nlp 英文词干归一 nltk
gitignore .gitignore 规则过滤 pathspec
legacy doc/ppt/xls/rtf/epub 老格式 firecrawl-anydoc(win_arm64 无 wheel,故不在 all 内)

未安装对应能力时自动降级(格式回退纯文本兜底 / 分词回退),不报错。

PST(Outlook 数据文件)解析内置:随包分发 pst-extract sidecar,开箱即用。

快速开始

库调用(最常用)

from treesearch import TreeSearch

# 惰性索引——首次搜索时自动建索引
ts = TreeSearch("./docs/")
results = ts.search("How to configure voice calls?")

CLI

# 默认:惰性索引 + 搜索
treesearch "How does auth work?" src/ docs/

# 子命令
treesearch index --paths src/ docs/ --force
treesearch search --db ./indexes/index.db --query "FTS5 search"
treesearch verify --db ./indexes/index.db
treesearch watch --paths docs/

设计要点

  • 树结构索引:文档解析为标题树,节点带路径/摘要;FTS5 建在节点级,命中可溯因到章节
  • 零向量、零切 chunk:FTS5 + BM25 关键词检索,结果可解释、可复现
  • 增量索引:stat/content 双指纹口径,文件级增量;schema 版本 bump 自动全量重建
  • 纯本地:SQLite(FTS5)存储,无服务依赖

License

Apache-2.0

Metadata

Release files for treesearchlib 1.2.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for treesearchlib 1.2.6
File Interpreter ABI Platform
treesearchlib-1.2.6-py3-none-any.whl Python 3 none any Details

Release files / treesearchlib-1.2.6-py3-none-any.whl

Download URL treesearchlib-1.2.6-py3-none-any.whl
Size 5.2 MB
Tags Python 3
SHA-256 checksum
How to use checksums
a272cb52606ee1c1c719bca7728dc5e6eff25d7d93fc4b06297bbb4d41d0975e
BLAKE2b-256 checksum
How to use checksums
6f6bac8a0518ffbface4340dcced1edcfdae8a440cdcaf321e0ee77cb51a5996
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.0

Release history Release notifications | RSS feed

1.2.12

1 release file

1.2.11

1 release file

1.2.10

1 release file

1.2.9

1 release file

1.2.8

1 release file

1.2.7

1 release file

This release

1.2.6 This release

1 release file

1.2.5

1 release file

1.2.4

1 release file

1.2.3

1 release file

1.2.2

1 release file

1.2.1

1 release file

1.2.0

1 release file

1.1.1

1 release file

1.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page