How I Rebuilt OpenStreetMap’s Category Model During GSoC
说明与用途
Nominatim 新的类别模型允许在单行中存储多个标签,改进了层次过滤并简化了排名。现有数据库的迁移在 47 分钟内完成。
问题
Nominatim’s original model allowed only one class/type pair per place, causing awkward handling of multi‑tag objects and lack of hierarchical filtering.
结果
The new category model allows a single database row to represent multiple tags, improves hierarchical filtering, and simplifies ranking logic. Migration of existing planet databases completed in under 47 minutes with minimal downtime.
工作流
- Added categories ltree[] column to place and placex tables
- Modified Lua import to generate categories and write one row per place
- Updated SQL ranking and trigger functions to use category paths
- Replaced class/type filtering with ltree queries
- Implemented lazy backfilling for existing rows during migration
- Optimized migration by disabling triggers and creating indexes after bulk update
证据
Nominatim only allowed one class/type pair per place.
The migration initially used lazy backfilling. When an existing row was touched, its category could be derived from the old class and type values.
Disabling the update trigger during the backfill and creating the indexes afterwards reduced that to about 47 minutes.
- 记录日期: 2026-09-22T06:30:36.939Z