]> git.openstreetmap.org Git - nominatim.git/log
nominatim.git
2 months agoMerge pull request #4197 from lonvia/refactor-query
Sarah Hoffmann [Tue, 15 Sep 2026 16:04:02 +0000 (18:04 +0200)]
Merge pull request #4197 from lonvia/refactor-query

Further refactoring of Query struct

2 months agoadd function to make final query node
Sarah Hoffmann [Tue, 15 Sep 2026 12:58:17 +0000 (14:58 +0200)]
add function to make final query node

2 months agomove break penalties into generic query struct
Sarah Hoffmann [Tue, 15 Sep 2026 09:29:13 +0000 (11:29 +0200)]
move break penalties into generic query struct

2 months agoadd helper function for computing penalty of partials
Sarah Hoffmann [Tue, 15 Sep 2026 07:36:14 +0000 (09:36 +0200)]
add helper function for computing penalty of partials

2 months agoadd special class for partial tokens
Sarah Hoffmann [Tue, 15 Sep 2026 07:18:02 +0000 (09:18 +0200)]
add special class for partial tokens

Moves the query edge information into this partial token to
avoid having information about the same entity in two different
places.

2 months agomove match_phrase() function to generic token
Sarah Hoffmann [Fri, 11 Sep 2026 14:57:51 +0000 (16:57 +0200)]
move match_phrase() function to generic token

This can be useful for other tokenizers as well.

2 months agoMerge pull request #4194 from lonvia/tokenizer-specific-sanitizers
Sarah Hoffmann [Fri, 11 Sep 2026 12:01:06 +0000 (14:01 +0200)]
Merge pull request #4194 from lonvia/tokenizer-specific-sanitizers

Tokenizer-specific sanitizers

2 months agodocument the new sanitizer settings
Sarah Hoffmann [Fri, 11 Sep 2026 08:54:14 +0000 (10:54 +0200)]
document the new sanitizer settings

2 months agomove language tagging sanitizer into icu tokenizer settings
Sarah Hoffmann [Fri, 11 Sep 2026 08:53:55 +0000 (10:53 +0200)]
move language tagging sanitizer into icu tokenizer settings

2 months agoallow additional sanitizer definitions in tokenizer config
Sarah Hoffmann [Thu, 10 Sep 2026 21:07:35 +0000 (23:07 +0200)]
allow additional sanitizer definitions in tokenizer config

2 months agoMerge pull request #4193 from lonvia/more-parameters-for-lang-tagger
Sarah Hoffmann [Thu, 10 Sep 2026 15:27:52 +0000 (17:27 +0200)]
Merge pull request #4193 from lonvia/more-parameters-for-lang-tagger

Add type and attribute properties to language tagging sanitizer

2 months agoMerge pull request #4192 from lonvia/fix-token-stripping
Sarah Hoffmann [Thu, 10 Sep 2026 10:04:42 +0000 (12:04 +0200)]
Merge pull request #4192 from lonvia/fix-token-stripping

Fix cleaning of token_info

2 months agorestrict fallback to sanitizer rules in tokenizer
Sarah Hoffmann [Thu, 10 Sep 2026 09:44:36 +0000 (11:44 +0200)]
restrict fallback to sanitizer rules in tokenizer

Only fall back to loading general sanitizer rules from the
ICU tokeinzer config when the ICU tokenizer is actually configured.

2 months agoadd type and attribute properties to language tagging sanitizer
Sarah Hoffmann [Thu, 10 Sep 2026 09:25:30 +0000 (11:25 +0200)]
add type and attribute properties to language tagging sanitizer

2 months agoMerge pull request #4191 from lonvia/split-up-tokenizer
Sarah Hoffmann [Thu, 10 Sep 2026 09:28:08 +0000 (11:28 +0200)]
Merge pull request #4191 from lonvia/split-up-tokenizer

Convert ICU tokenizer from module to package

2 months agofix cleaning of token_info
Sarah Hoffmann [Thu, 10 Sep 2026 08:22:57 +0000 (10:22 +0200)]
fix cleaning of token_info

2 months agosplit ICU tokenizer into multiple files
Sarah Hoffmann [Thu, 10 Sep 2026 07:49:36 +0000 (09:49 +0200)]
split ICU tokenizer into multiple files

2 months agoallow tokenizers to be packages
Sarah Hoffmann [Wed, 9 Sep 2026 14:06:41 +0000 (16:06 +0200)]
allow tokenizers to be packages

2 months agoMerge pull request #4189 from lonvia/falcon-traceback
Sarah Hoffmann [Thu, 10 Sep 2026 07:11:25 +0000 (09:11 +0200)]
Merge pull request #4189 from lonvia/falcon-traceback

Add a fallback exception handler for the falcon server

2 months agofalcon server: print traceback in debug view in case of internal errors
Sarah Hoffmann [Wed, 9 Sep 2026 13:40:28 +0000 (15:40 +0200)]
falcon server: print traceback in debug view in case of internal errors

2 months agoMerge pull request #4184 from pawank925/fix-secondary-main-tags-extratags
Sarah Hoffmann [Wed, 9 Sep 2026 08:07:48 +0000 (10:07 +0200)]
Merge pull request #4184 from pawank925/fix-secondary-main-tags-extratags

keep secondary main tags in extratags

2 months agoUpdate tests for secondary main tags in extratags
pawank925 [Tue, 8 Sep 2026 11:17:08 +0000 (16:47 +0530)]
Update tests for secondary main tags in extratags

Secondary main tags that lose the class/type selection are now kept in
extratags when extra tags are collected. Update the affected BDD tests
to expect the secondary main tags in the extratags column:

* main_with_extra: the losing bridge/highway main tag now shows up in
  extratags.
* simple.feature: split the extratags style into its own scenario
  because only that style collects the secondary place tag into
  extratags.

2 months agoPush secondary main tags into extratags
pawank925 [Tue, 8 Sep 2026 11:17:08 +0000 (16:47 +0530)]
Push secondary main tags into extratags

When an object carries several main tags, Nominatim converts all of
them into categories but only places a single one into class/type.
The remaining main tags were dropped entirely, so they were no longer
accessible in the results (categories are not returned).

Keep secondary main tags in extratags instead of removing them from
the extratags set. Only the winning main tag that became class/type is
excluded from extratags. Because extratags are only collected when the
Lua style is configured to keep extra tags, the behaviour in the
default import (extra tags disabled) is unchanged.

Adds a BDD test covering secondary main tags being kept in extratags.

2 months agoMerge pull request #4188 from lonvia/fix-pygments-regression
Sarah Hoffmann [Tue, 8 Sep 2026 08:30:51 +0000 (10:30 +0200)]
Merge pull request #4188 from lonvia/fix-pygments-regression

Fix SQL debug output for newer pygments versions

2 months agoadd semicolon after SQL debug output
Sarah Hoffmann [Mon, 7 Sep 2026 20:51:42 +0000 (22:51 +0200)]
add semicolon after SQL debug output

2 months agomanual line breaaking for pygments formatted HTML
Sarah Hoffmann [Mon, 7 Sep 2026 20:48:01 +0000 (22:48 +0200)]
manual line breaaking for pygments formatted HTML

Works around a regression in Pygments in 2.20.0 where the
lineseparator is suddenly HTML escaped.

2 months agoMerge pull request #4186 from lonvia/ci-ubuntu-26
Sarah Hoffmann [Sun, 6 Sep 2026 16:04:34 +0000 (18:04 +0200)]
Merge pull request #4186 from lonvia/ci-ubuntu-26

CI: switch to Ubunti24/26 images

2 months agoCI: switch to Ubuntu 26
Sarah Hoffmann [Sun, 6 Sep 2026 09:57:45 +0000 (11:57 +0200)]
CI: switch to Ubuntu 26

2 months agoCI: update action scripts
Sarah Hoffmann [Sun, 6 Sep 2026 09:52:27 +0000 (11:52 +0200)]
CI: update action scripts

2 months agorelease 5.3.2.post11
Sarah Hoffmann [Sat, 5 Sep 2026 15:45:41 +0000 (17:45 +0200)]
release 5.3.2.post11

2 months agoMerge remote-tracking branch 'upstream/master'
Sarah Hoffmann [Sat, 5 Sep 2026 15:23:14 +0000 (17:23 +0200)]
Merge remote-tracking branch 'upstream/master'

2 months agoMerge pull request #4185 from lonvia/us-postcode-radius
Sarah Hoffmann [Sat, 5 Sep 2026 15:17:55 +0000 (17:17 +0200)]
Merge pull request #4185 from lonvia/us-postcode-radius

Increase postcode extent for the US

2 months agoMerge pull request #4177 from justpriyanshu/fix-4172-drop-unwanted-categories
Sarah Hoffmann [Sat, 5 Sep 2026 14:11:19 +0000 (16:11 +0200)]
Merge pull request #4177 from justpriyanshu/fix-4172-drop-unwanted-categories

Fix 4172 drop unwanted categories

2 months agoincrease postcode extent for the US
Sarah Hoffmann [Sat, 5 Sep 2026 12:20:17 +0000 (14:20 +0200)]
increase postcode extent for the US

2 months agoadd test for unwanted categories in rank computation
justpriyanshu [Fri, 28 Aug 2026 09:15:47 +0000 (09:15 +0000)]
add test for unwanted categories in rank computation

3 months agoMerge pull request #4171 from pawank925/fix-unnamed-street-pois
Sarah Hoffmann [Wed, 2 Sep 2026 18:42:48 +0000 (20:42 +0200)]
Merge pull request #4171 from pawank925/fix-unnamed-street-pois

Make POIs on unnamed streets searchable by address #4133

3 months agoMerge pull request #4179 from lonvia/improve-parent-search
Sarah Hoffmann [Tue, 1 Sep 2026 18:59:42 +0000 (20:59 +0200)]
Merge pull request #4179 from lonvia/improve-parent-search

Switch nearest road/place search to KNN

3 months agodecrease the radius for nearest mapping of streets
Sarah Hoffmann [Tue, 1 Sep 2026 14:53:50 +0000 (16:53 +0200)]
decrease the radius for nearest mapping of streets

3 months agoslightly increase update radius for changed streets
Sarah Hoffmann [Tue, 25 Aug 2026 18:22:55 +0000 (20:22 +0200)]
slightly increase update radius for changed streets

3 months agouse knn to find nearest street and place
Sarah Hoffmann [Tue, 25 Aug 2026 17:43:47 +0000 (19:43 +0200)]
use knn to find nearest street and place

3 months agouse knn search to parent with nearest road
Sarah Hoffmann [Tue, 25 Aug 2026 15:19:45 +0000 (17:19 +0200)]
use knn search to parent with nearest road

3 months agoignore unwanted categories when computing ranks
justpriyanshu [Fri, 28 Aug 2026 08:58:09 +0000 (08:58 +0000)]
ignore unwanted categories when computing ranks

The checks for unwanted highway and boundary categories were only used
to decide whether a place is rankable at all. The offending categories
remained in the category list, so compute_place_rank() would still pick
up their ranks. Move the checks into drop_unwanted_categories() and
filter the categories before computing ranks.

Refs #4172

3 months agoMerge pull request #4166 from Itz-Agasta/docs-category-series
Sarah Hoffmann [Sat, 22 Aug 2026 19:58:19 +0000 (21:58 +0200)]
Merge pull request #4166 from Itz-Agasta/docs-category-series

Update the documentation for the category series

3 months agoAdd a migration note about the categories column
Itz-Agasta [Fri, 14 Aug 2026 07:24:37 +0000 (12:54 +0530)]
Add a migration note about the categories column

3 months agoUpdate the details documentation for merged place entries
Itz-Agasta [Fri, 14 Aug 2026 07:24:37 +0000 (12:54 +0530)]
Update the details documentation for merged place entries

3 months agoDocument the include and exclude search parameters
Itz-Agasta [Fri, 14 Aug 2026 07:24:37 +0000 (12:54 +0530)]
Document the include and exclude search parameters

3 months agoDocument categories in the import style documentation
Itz-Agasta [Fri, 14 Aug 2026 07:24:37 +0000 (12:54 +0530)]
Document categories in the import style documentation

An object with several main tags gets one database entry with a category
per tag now, instead of one entry per tag. Describe how a category is
built from a main tag and which of the main tags ends up as the class and
type of the place. Fallback tags always contribute a category now, they
only lose the race for class and type.

3 months agoUpdate the database layout documentation
Itz-Agasta [Fri, 14 Aug 2026 07:24:37 +0000 (12:54 +0530)]
Update the database layout documentation

The place table holds a single row per OSM object now, with a categories
column that carries all of its main tags. Document that, the categories
column on placex and the tables that were added since the page was last
touched: place_entrance, placex_entrance, place_associated_street and
location_area_country. The place_classtype tables are gone, so drop them
from the list of auxiliary tables.

Also bring the diagrams back in line with the schema. search_name lost
its search_rank column a while ago and location_postcodes gained is_area,
while its centroid was missing from the diagram because of a typo.

3 months agoMerge pull request #4164 from Itz-Agasta/category-support
Sarah Hoffmann [Tue, 18 Aug 2026 13:43:26 +0000 (15:43 +0200)]
Merge pull request #4164 from Itz-Agasta/category-support

Add category filters to the search API

3 months agoAdd search terms for POIs on unnamed streets
pawank925 [Sun, 16 Aug 2026 18:01:26 +0000 (23:31 +0530)]
Add search terms for POIs on unnamed streets

When a POI is parented to an unnamed street, the street has no entry in
the search_name table. The POI then gets no address terms at all and
can only be found by its name. Use the address objects of the parent
from place_addressline to fill in the missing address terms.

3 months agoAdd BDD tests for repeated include/exclude parameters
Itz-Agasta [Sat, 15 Aug 2026 15:34:45 +0000 (21:04 +0530)]
Add BDD tests for repeated include/exclude parameters

A parameter listed more than once in the step table is now sent as a
repeated request parameter.

3 months agoUse the categories column for category matching on SQLite as well
Itz-Agasta [Sat, 15 Aug 2026 15:34:30 +0000 (21:04 +0530)]
Use the categories column for category matching on SQLite as well

CategoryMatch fell back to the class/type columns on SQLite only
because the categories column was unreadable there. With the result
processor fixed, the substring emulation works for all cases, so the
two functions collapse into one. It also matches merged rows, where
the class/type pair only carries the first of several categories.

The placex(class_, type) index stays, it is still used by the
qualifier restriction of the name searches.

3 months agoOnly accept underscores in category filters
Itz-Agasta [Sat, 15 Aug 2026 15:34:22 +0000 (21:04 +0530)]
Only accept underscores in category filters

The conversion from hyphens to underscores in the Lua code exists for
compatibility with OSM tags we have no influence over. The API can be
strict instead.

3 months agoMake get_all() an abstract method of ASGIAdaptor
Itz-Agasta [Sat, 15 Aug 2026 15:34:10 +0000 (21:04 +0530)]
Make get_all() an abstract method of ASGIAdaptor

A default implementation that silently returns only the first value
hides a missing override in a new adaptor implementation.

3 months agoAdd include/exclude parameters to the search endpoint
Itz-Agasta [Wed, 12 Aug 2026 08:10:06 +0000 (13:40 +0530)]
Add include/exclude parameters to the search endpoint

3 months agoFilter search results by category
Itz-Agasta [Wed, 12 Aug 2026 08:10:06 +0000 (13:40 +0530)]
Filter search results by category

Applies to every search returning placex rows. Sources without
categories return nothing when an include filter is given.

3 months agoAdd include/exclude category filters to SearchDetails
Itz-Agasta [Wed, 12 Aug 2026 08:10:06 +0000 (13:40 +0530)]
Add include/exclude category filters to SearchDetails

3 months agoLet adaptors read repeated request parameters
Itz-Agasta [Wed, 12 Aug 2026 08:10:06 +0000 (13:40 +0530)]
Let adaptors read repeated request parameters

Not an abstract method, so that external adaptors keep working. They
then see only the first value of a repeated parameter.

3 months agoParse the array literal returned for the categories column
Itz-Agasta [Wed, 12 Aug 2026 08:10:06 +0000 (13:40 +0530)]
Parse the array literal returned for the categories column

The driver does not know ltree[] and hands out the array literal as a
string. The SQLite export then joined the characters of that string
instead of the categories.

3 months agorelease 5.3.2.post9
Sarah Hoffmann [Sun, 9 Aug 2026 09:07:36 +0000 (11:07 +0200)]
release 5.3.2.post9

3 months agoMerge remote-tracking branch 'upstream/master'
Sarah Hoffmann [Sun, 9 Aug 2026 08:19:16 +0000 (10:19 +0200)]
Merge remote-tracking branch 'upstream/master'

3 months agoMerge pull request #4163 from Itz-Agasta/category-support
Sarah Hoffmann [Sun, 9 Aug 2026 08:12:41 +0000 (10:12 +0200)]
Merge pull request #4163 from Itz-Agasta/category-support

Remove the place_classtype tables

3 months agoDo not drop the place_classtype tables on migration
Itz-Agasta [Sun, 9 Aug 2026 06:56:31 +0000 (12:26 +0530)]
Do not drop the place_classtype tables on migration

Migration and frontend restart do not happen at the same time. The documented order is to migrate first and restart the API afterwards, so there is a window where the old frontend code is still running against a migrated database. That code caches which place_classtype_* tables exist and would query tables that are already gone.

Leave the tables in place instead and document in the migration guide how to drop them manually once all frontends run the new version.

3 months agorelease 5.3.2.post8
Sarah Hoffmann [Sat, 8 Aug 2026 13:48:08 +0000 (15:48 +0200)]
release 5.3.2.post8

3 months agoMerge remote-tracking branch 'upstream/master'
Sarah Hoffmann [Sat, 8 Aug 2026 12:16:02 +0000 (14:16 +0200)]
Merge remote-tracking branch 'upstream/master'

3 months agoDeprecate --min option instead of removing it
Itz-Agasta [Sat, 8 Aug 2026 07:10:07 +0000 (12:40 +0530)]
Deprecate --min option instead of removing it

3 months agoDrop the place_classtype tables on migration
Itz-Agasta [Thu, 6 Aug 2026 09:02:07 +0000 (14:32 +0530)]
Drop the place_classtype tables on migration

Nothing creates or reads them anymore, so a migrated database would keep
carrying them around for nothing. On a planet that is 428 tables and a
good 8GB.

The migration runs after the POI backfill, which still needs the table
names to work out which rows to fill in.

3 months agoStop copying the place_classtype tables into SQLite
Itz-Agasta [Thu, 6 Aug 2026 09:01:52 +0000 (14:31 +0530)]
Stop copying the place_classtype tables into SQLite

The conversion mirrored every table into the SQLite file and built a
spatial index on each of them. It also wrote a minimal stand-in for
pg_tables, which was only there so that get_class_table() could look the
tables up on SQLite. None of it is needed now that category search
matches on class/type.

3 months agoRemove Connection.get_class_table()
Itz-Agasta [Thu, 6 Aug 2026 09:01:17 +0000 (14:31 +0530)]
Remove Connection.get_class_table()

The POI and near searches went through this to find the table for a
category. Both query the categories column directly since the switch, so
the helper has had no callers left.

3 months agoStop creating the place_classtype tables from special phrases
Itz-Agasta [Thu, 6 Aug 2026 09:01:06 +0000 (14:31 +0530)]
Stop creating the place_classtype tables from special phrases

The special phrase import created one table per class/type pair, indexed
it on centroid and place_id and granted the webuser access to it. Nothing
reads those tables anymore, so all of that goes. What is left is
collecting the phrases and handing them to the tokenizer.

The --min option only decided which of the tables were created, it never
filtered the phrases themselves, so it has no meaning without them. It is
removed together with get_classtype_pairs().

The table counters in the statistics handler would report zero forever.

3 months agoStop maintaining the place_classtype tables on updates
Itz-Agasta [Thu, 6 Aug 2026 09:00:55 +0000 (14:30 +0530)]
Stop maintaining the place_classtype tables on updates

Category search reads the categories column now, so the rows the insert
and delete triggers keep in sync are not read by anything anymore. Both
did a pg_tables lookup on every placex insert and delete to find out
whether a table for the class/type exists, which is pure overhead on
diff updates.

The webuser does not need read access to the tables either.

3 months agoMerge pull request #4162 from lonvia/restrict-queries
Sarah Hoffmann [Thu, 6 Aug 2026 09:00:20 +0000 (11:00 +0200)]
Merge pull request #4162 from lonvia/restrict-queries

Add restrictions to length of search queries

3 months agodebug output: escape HTML values
marc tobias [Wed, 5 Aug 2026 13:29:48 +0000 (15:29 +0200)]
debug output: escape HTML values

3 months agoadd default query preprocessor to restrict queries to 500 chars
Sarah Hoffmann [Wed, 5 Aug 2026 14:01:11 +0000 (16:01 +0200)]
add default query preprocessor to restrict queries to 500 chars

3 months agoalso restrict length of full words to 255
Sarah Hoffmann [Wed, 5 Aug 2026 13:40:41 +0000 (15:40 +0200)]
also restrict length of full words to 255

3 months agorestrict number of alloable tokens per query to 50
Sarah Hoffmann [Wed, 5 Aug 2026 13:37:43 +0000 (15:37 +0200)]
restrict number of alloable tokens per query to 50

3 months agodrop words longer than 255 characters
Sarah Hoffmann [Wed, 5 Aug 2026 13:27:39 +0000 (15:27 +0200)]
drop words longer than 255 characters

It is not possible in OSM to have names that are longer than that.

3 months agoMerge pull request #4161 from mtmail/disable-debug-output-by-default
Sarah Hoffmann [Thu, 6 Aug 2026 07:09:37 +0000 (09:09 +0200)]
Merge pull request #4161 from mtmail/disable-debug-output-by-default

disable debug=1 output by default

3 months agoMerge pull request #4146 from Itz-Agasta/category-support
Sarah Hoffmann [Thu, 6 Aug 2026 07:05:10 +0000 (09:05 +0200)]
Merge pull request #4146 from Itz-Agasta/category-support

Use ltree categories column instead of place_classtype tables

3 months agoSimplify the POI backfill by filtering the classtype tables
Itz-Agasta [Wed, 5 Aug 2026 14:59:32 +0000 (20:29 +0530)]
Simplify the POI backfill by filtering the classtype tables

Only consider place_classtype_* tables whose name consists of valid
ltree label characters. The class and type of the rows to update then
are valid labels by construction and do not need to be sanitized.

3 months agodisable debug=1 output by default
marc tobias [Tue, 4 Aug 2026 21:42:25 +0000 (23:42 +0200)]
disable debug=1 output by default

4 months agoRestrict the POI category backfill to searchable categories
Itz-Agasta [Sat, 1 Aug 2026 06:43:48 +0000 (12:13 +0530)]
Restrict the POI category backfill to searchable categories

Only class/type combinations that have a place_classtype_* table can be
reached through a special phrase, and those are exactly the ones master
resolved through Connection.get_class_table(). Look the tables up the
same way and restrict the UPDATE to rows that match one. That takes the
planet from 303,652,952 to 46,222,253 rows and skips the step entirely
on databases that never imported special phrases.

The value expression now matches backfill_categories, so a POI also
picks up the osm.place.* category from its extratags.

Categories without a table are no longer found by the [key=value]
syntax on a migrated database. Those need a reimport.

Also unskip the [club=scout] search test. It asserted on the reported
class/type, which is the row's own main tag rather than the queried
category. Check for the two deterministic objects instead; the third
result is subject to deduplication.

4 months agoMerge pull request #4157 from lonvia/tweak-country-languages
Sarah Hoffmann [Thu, 30 Jul 2026 17:25:12 +0000 (19:25 +0200)]
Merge pull request #4157 from lonvia/tweak-country-languages

Remove srp from languages for Montenegro

4 months agoMerge pull request #4155 from mtmail/validate-layer-parameter
Sarah Hoffmann [Thu, 30 Jul 2026 14:05:56 +0000 (16:05 +0200)]
Merge pull request #4155 from mtmail/validate-layer-parameter

validate layer URL parameter values

4 months agoremove srp from languages for Montenegro
Sarah Hoffmann [Thu, 30 Jul 2026 13:46:57 +0000 (15:46 +0200)]
remove srp from languages for Montenegro

It's just the 3-letter code for the already existing sr.

4 months agoMerge pull request #4149 from AyushDharDubey/issue_4125
Sarah Hoffmann [Thu, 30 Jul 2026 09:22:35 +0000 (11:22 +0200)]
Merge pull request #4149 from AyushDharDubey/issue_4125

Add `clean_multilingual_names` Sanitizer

4 months agoBackfill the categories column for POIs
Itz-Agasta [Thu, 30 Jul 2026 09:10:33 +0000 (14:40 +0530)]
Backfill the categories column for POIs

The backfill in the previous migration only filled the rank_address < 26
rows that place linking needs. Category search reads the column for POIs
as well, so a migrated database would find almost nothing for them.

Only the class/type category can be derived from placex, which is the
same one the lazy backfill in placex_update adds. Categories from
secondary tags still need a reimport.

4 months agoDrop the obsolete categories index on migration
Itz-Agasta [Thu, 30 Jul 2026 08:57:29 +0000 (14:27 +0530)]
Drop the obsolete categories index on migration

The earlier migration does not create idx_placex_categories anymore, so
this only cleans up after databases that ran it before that change. Drop
it before creating the combined index, so that the two are never on disk
at the same time.

4 months agoAlways create the combined centroid/categories index
Itz-Agasta [Thu, 30 Jul 2026 07:19:14 +0000 (12:49 +0530)]
Always create the combined centroid/categories index

Reverse queries will need the index as well, so it is not restricted to
databases with a search_name table.

4 months agoUse a single query for the POI category search
Itz-Agasta [Thu, 30 Jul 2026 07:19:14 +0000 (12:49 +0530)]
Use a single query for the POI category search

The near/small-radius branch searched placex directly while the other
branch went through the place_classtype tables. Now that both go through
the categories column, the only remaining differences were the importance
column and the linked_place_id filter, so fold them into one query.

The remaining geometry conditions in the near branch move to the centroid
as well, so that the combined centroid/categories index can serve the
spatial and the category condition at once. Linked places are now excluded
in all cases, as they are duplicates of the place they are linked to.

4 months agoMatch categories on the centroid instead of the geometry
Itz-Agasta [Mon, 27 Jul 2026 11:16:58 +0000 (16:46 +0530)]
Match categories on the centroid instead of the geometry

Category search used to run against the place_classtype tables, which
hold a centroid and index it. Moving to the categories column also
moved the searches onto placex.geometry, which changed what the filter
means and traded a small centroid index for the 22GB geometry index
over the whole of placex.

Put both searches back on the centroid, where the combined
centroid/categories index can serve them. This also reverts the
geometry prefilter in the near search: it was there to prune the
non-spatial categories index, and the combined index prunes on its
own.

Note that the near_radius branch of the POI search is left alone. It
queried placex.geometry before this change as well.

4 months agoIndex placex centroid for the SQLite category search
Itz-Agasta [Mon, 27 Jul 2026 11:16:58 +0000 (16:46 +0530)]
Index placex centroid for the SQLite category search

SQLite has no ltree, so category search matches on class/type, but it
still needs the spatial part of the query to be indexed. Only
placex.geometry had a spatial index, so moving the category searches
onto the centroid would leave them without one and the SpatialIndex
subquery would match nothing.

4 months agoUse a combined centroid/categories index for category search
Itz-Agasta [Mon, 27 Jul 2026 11:16:20 +0000 (16:46 +0530)]
Use a combined centroid/categories index for category search

The plain ltree index on categories is not spatial, so a category
search bounded by a viewbox or a search area had to combine it with
a second index and AND two large bitmaps together. On a full planet
that made the near search take 510ms and the bounded POI search
106ms, against 22ms and 0.7ms for the place_classtype tables they
replace.

Put the centroid in front of the categories in a combined GiST index
instead. Measured on a full planet import, that brings the POI search
to 1.2ms and the near search to 74ms.

Two details on the definition. The centroid comes first because a
GiST index is ineffective when its first column has few distinct
values, which is exactly what the lossy signatures of the categories
column are; it also builds faster and smaller (12:22 and 5125MB
against 19:45 and 5376MB for the other order). The index is not
partial because the predicate would otherwise make it unusable for
queries on the centroid alone, which cost only 10 to 20% on the
category queries but takes a plain centroid lookup from a sequential
scan to an index scan.

siglen=8 keeps the size manageable. The default for gist__ltree_ops
is 28 bytes, which on a planet with full category coverage would put
the index well above the 22GB it takes now.

The index gets a new name, so the now unused idx_placex_categories
is simply dropped from the earlier migration rather than replaced.
Since that migration is already released, the new index needs a
migration step of its own.

4 months agoApply spatial pruning in near search
Itz-Agasta [Tue, 21 Jul 2026 17:16:38 +0000 (22:46 +0530)]
Apply spatial pruning in near search

Introduce search_area to prune with the geometry GiST index and
keep the centroid containment as a recheck. When rank_address > 9
and the geometry is an area, use the geometry; otherwise expand
the centroid by 0.05. Update the join to intersect with search_area
and use ST_CoveredBy(search_area) for containment.

4 months agoIndex placex(class,type) for the SQLite category search
Itz-Agasta [Thu, 9 Jul 2026 06:19:32 +0000 (11:49 +0530)]
Index placex(class,type) for the SQLite category search

SQLite has no ltree, so category search matches on class/type there and
needs a matching composite index.

4 months agoKeep the object class/type in the result category field
Itz-Agasta [Thu, 9 Jul 2026 06:19:04 +0000 (11:49 +0530)]
Keep the object class/type in the result category field

Revert the per-category match tracking; report the row's own class/type
as before and collapse the POI query into a single indexed lookup.
Re-skip the club=scout scenario: a merged placex row cannot surface a
non-winning searched category under this model.(we will fix it soon)

4 months agoRework category matching: move to sql functions, reject invalid
Itz-Agasta [Thu, 9 Jul 2026 06:17:21 +0000 (11:47 +0530)]
Rework category matching: move to sql functions, reject invalid
categories

Relocate CategoryMatch to sqlalchemy_functions.py alongside the other
compiled functions. Reject class/type special tokens that cannot form a
valid ltree at token collection, so search never emits an unindexed
class/type fallback; category_filter now always hits the ltree index.
Update the S-token test mocks to carry a class.

4 months agoUpdate search tests for the categories column
Itz-Agasta [Mon, 6 Jul 2026 12:21:30 +0000 (17:51 +0530)]
Update search tests for the categories column

Populate categories in the placex test fixture, drop the obsolete place_classtype table helper and its scenarios, and unskip the key/value category search BDD test.

4 months agoQuery the categories column for POI and near search
Itz-Agasta [Mon, 6 Jul 2026 12:20:40 +0000 (17:50 +0530)]
Query the categories column for POI and near search

Replace the place_classtype_* table lookups in PoiSearch and NearSearch with queries against the ltree categories column  (categories <@ 'osm.<class>.<type>'), backed by the GiST index. SQLite, which has no ltree, falls back to class/type equality. Because a merged placex row now carries several categories, both searches report the searched category rather than the row's class/type. get_class_table() is kept with a TODO; the place_classtype_* tables are removed in a follow-up PR.

4 months agoAdd ltree categories column to the API placex schema
Itz-Agasta [Mon, 6 Jul 2026 12:00:29 +0000 (17:30 +0530)]
Add ltree categories column to the API placex schema

Introduce a CategoryArray SQLAlchemy type that maps to the native ltree[] column on PostgreSQL and to comma-separated text on SQLite. Register the categories column on the placex table so the search side can query it.