Sarah Hoffmann [Fri, 27 Nov 2026 10:56:05 +0000 (11:56 +0100)]
Remove private parking spaces from index (#4247)
There are about 850k private `amenity=parking` in OSM which don't
contribute much to searchability. This removes them. I've intentionally
left parkings with `access=customer` and `access=destination` so that
searches like `parking near IKEA Berlin` still work (to the extend that
they work, of course).
Sarah Hoffmann [Fri, 27 Nov 2026 10:08:06 +0000 (11:08 +0100)]
Introduce table for saving label-member relations (#4246)
This adds a new table `place_label_members` which stores node IDs that
are a member with role 'label' in a relation. The table is filled by
osm2pgsql. A membership is considered valid only when there is exactly
one label member with a node in a relation. The linking code now uses
that table to look up members instead of going through the members
loaded from `planet_osm_rels`. This should be a bit faster and has the
added bonus that it now can reject label nodes when they appear in more
than one relation. This was a source of confusion for Nominatim.
This is the first in a series of PRs to stop Nominatim from using the
osm2pgsql middle tables. This is in preparation for the next version of
osm2pgsql which will have a [new middle
implementation](https://osm2pgsql.org/project-coda/) that is a lot more
compact but no longer accessible in PostgreSQL.
Sarah Hoffmann [Thu, 26 Nov 2026 14:19:59 +0000 (15:19 +0100)]
Add named rapids to index (#4245)
This adds extra places to the index for OSM objects tagged with `rapids`
and `rapids:name`.
The tagging for rapids is a bit unfortunate as the tag can contain the
difficulty of the rapids as a number or even a number range. This makes
the `rapids` tag itself unsuitable for use as a main tag. So this PR
adds the ability to set a custom main tag when adding additional place
variants. For the rapids, it ends up with `rapids=yes` as the main tag,
while the `rapids` tag itself is pushed into extratags so that the rapid
classification remains accessible.
Also, `rapids=no` + `rapids:name` are ignored. Just doesn't make sense.
Sarah Hoffmann [Thu, 26 Nov 2026 08:45:36 +0000 (09:45 +0100)]
Lua: fix bug in clearing of main tag filter (#4244)
This fixes a bug in Lua where a table was accidentally modified by being
iterated over. The bug has been present for a long time but only
manifested until recently with an occasionally failing BDD test.
Production is unlikely to be affected because even custom scripts will
rarely reset the main tag list filter. They will only set it once and
then modify it further.
Sarah Hoffmann [Wed, 25 Nov 2026 18:30:15 +0000 (19:30 +0100)]
Smaller improvements to normalization rules (#4243)
* Use ICU's builtin NFKC normlaization which makes quite a few of the
custom rules needless.
* Finally fix #3718.
* Read the wikipedia article on the palochka, which metioned that '1' is
a common replacement for it. Use that at transliteration.
These rules will only have an effect on newly imported databases.
Sarah Hoffmann [Wed, 25 Nov 2026 14:15:31 +0000 (15:15 +0100)]
Improve main class and category assignment in Lua (#4242)
This introduces hooks for determining the main tag and categories in the
Lua scripts. Right now the functions behind the hooks are hard-coded but
will be made configurable in a follow-up PR.
The function for determining the main tag now takes semantic priorities
into account instead of going simply by alphabetic order. As a result we
can go back to determining the place ranks directly from the main tag
instead of doing heuristics over the categories. The latter caused quite
a few odd misclassifications.
Categories are still simply derived from the candidates for the main tag
with a few tag combinations blacklisted.
This also resurrects the ability to create more than one place object
for a single OSM object. This is to cater for bridges and tunnels. I had
considered just giving bridges and tunnels the priority and ignoring the
underlying highways/railways but there are [bridges that form part of an
address](https://www.openstreetmap.org/way/122237921). The highway
entries are required for those.
Also fixes a bug in the recently introduced `is_area()` function and
reworks some of the osm2pgsql BDD tests.
Sarah Hoffmann [Wed, 18 Nov 2026 19:08:14 +0000 (20:08 +0100)]
remove lazy backfill for categories
Migration now has filled the categories that are important for existing
databases. For new tables the backfill interferes with category
selection from Lua.
Sarah Hoffmann [Sat, 21 Nov 2026 18:58:19 +0000 (19:58 +0100)]
Ranking tweaks (#4240)
This adapts ranking for some place and waterway features that have
appeared in the top tagging ranks over the last few years.
Most important change: `place=square` is now ranked as a highway. This
fixes a long-standing omission by Nominatim which caused people to be
confused why their `addr:street` isn't properly linked to a square.
Using `addr:place` works and people have used it as a work-around but
it's really not right. With the ranking change, Nominatim will now
expect a `addr:street` in the address in order to link properly with the
place. `addr:place` will keep working through its general fallback
handling, so nothing breaks in the existing data.
Sarah Hoffmann [Wed, 18 Nov 2026 08:11:41 +0000 (09:11 +0100)]
Optionally ignore class parameter on details (#4239)
The `class` parameter in the `details()` functions and API endpoint is
now only used as a hint which result to return when there are multiple
entries for an OSM object available.
Additional test borrowed from #4195 by @davidbian1.
Also enables a few skipped BDD tests around /details that have long
since been fix.
Sarah Hoffmann [Mon, 16 Nov 2026 08:43:53 +0000 (09:43 +0100)]
Add check for duplicate partial terms in word table (#4233)
Adds a check to `nominatim admin --check-database` for duplicated
partial terms in the word table, as suggested in #4232. Two processes
importing or indexing the same database at the same time can create the
same partial term twice; any query containing it then fails with `assert
snode.partial is None` in the query analyzer, which is hard to diagnose
from the API's 500 alone. The check is a single GROUP BY on the word
table (a few seconds on a country extract) and is not applicable when
there is no word table.
Sarah Hoffmann [Mon, 16 Nov 2026 08:43:21 +0000 (09:43 +0100)]
Remove remaining hard-coded object filtering from SQL code (#4237)
This removes dropping of unwanted highway and boundary types for good
from the SQL code. #4177 already dropped the resulting categories but
still left the dropping as a hard-coded function in SQL. This PR now
moves the code to Lua making it fully configurable.
The Lua version isn't an exact copy of the old code as it doesn't make
fully sense anymore. For highways it is largely enough to drop all
unnamed pedestrian to achieve the general effect of the SQL code.
Boundary dropping works about the same.
The code also adds a bit more sophisticated geometry building for
highway ways: unless `area=yes` is set, it will prefer to build a
linestring (excepting rest areas, just as is done [by
osm-carto](https://github.com/openstreetmap-carto/openstreetmap-carto/blob/003cefdd67918e8317e9753312ec3327d78f5d1f/openstreetmap-carto-flex.lua#L251)).
Sarah Hoffmann [Tue, 3 Nov 2026 09:32:09 +0000 (10:32 +0100)]
Add support for multiple postcode patterns per country (#4235)
This adds support for countries switching their postcode system to allow
accepting the old and new postcode patterns. Concretely adds support for
the new postcode system in Nigeria.
The Nigeria case shows that different patterns may also have differently
sized coverage areas. Therefore the extent configuration moves from
per-country extent to per-postcode pattern extent. The code is written
in a way now that we can even move to per-postcode extent in the future.
Looking through the code I also noticed that postcodes from external
CSVs still use the old schema of normalising through the analyser. That
is incompatible with the postcode parser in the search code. So this PR
also moves the DSC reading code to using the postcode pattern matcher.
acpuchades [Fri, 30 Oct 2026 10:03:06 +0000 (11:03 +0100)]
add check for duplicate partial terms in word table
When two processes import or index the same database at the same time,
they can create the same partial term twice. Queries containing such a
term then fail with an assertion in the query analyzer, which is hard to
diagnose from the API's 500 response alone.
Sarah Hoffmann [Tue, 27 Oct 2026 21:26:01 +0000 (22:26 +0100)]
Avoid deleting from array that is being looped over (#4228)
This fixes a case of deleting an element from an array while looping
over the array in the postcode sanitizer, as found by Copilot (see
#4227).
Python will jump over the the next element after having deleted one, so
that a postcode following an invalid one might not be handled. This case
is very unlikely to appear in the real world because addresses can only
be input with a single postcode. You'd have to use a special sanitizer
to duplicate the entry. And also change the default of actually keeping
the postcode.
To keep the frequent case lean, simply recreate the address item list
without the filtered postcodes in the rare case that a postcode needs to
be deleted.
Sarah Hoffmann [Tue, 20 Oct 2026 08:18:35 +0000 (10:18 +0200)]
Add support for addr:substreet and addr:parentstreet (#4226)
This adds support for the [special addressing schema in the
UK](https://wiki.openstreetmap.org/wiki/Addresses_in_the_United_Kingdom)
which may consist of two streets or a place and a street.
The implementation follows what is described in the wiki with support
for `addr:street`+ `addr:parentstreet` and `addr:substreet` +
`addr:parentstreet`. Also possible are combinations of `addr:place` +
`addr:parentstreet` and `addr:housename` + `addr:street` (although here
`addr:unit` support is missing for completeness).
Not supported is the combination of `addr:substreet` + `addr:street`
which is in relatively wide usage. It ends up interpreting the
`addr:substreet` as a suburb. The result is that the combination can
still be found but will be displayed wrongly.
Internally, this is solved as follows:
* addr:substreet is aliased to addr:place in the osm2pgsql import
configuration
* address ranks for results are slightly changed:
* addr:place parents are assigned rank 28 (was 18-25 before)
* addr:street parents are always assigned 27 (was 26-27 before)
* addr:parentstreet is inserted at rank 26, when it exists
Standard output formats should be largely uneffected except roads
showing up at rank 27 instead of 26. However, if you have implemented
custom output formatters, you might want to review your implementation.
Sarah Hoffmann [Tue, 22 Sep 2026 11:59:19 +0000 (13:59 +0200)]
add support for addr:substreet and addr:parentstreet
addr:substreet is aliased to addr:place and output ranking slightly
changed: addr:place is 28, addr:street always 27, while addr:parentstreet
is inserted at 26. This might or might not break some custom
formatter.
Sarah Hoffmann [Sun, 18 Oct 2026 09:12:15 +0000 (11:12 +0200)]
fix joining of words in structured postcode phrases (#4224)
## Summary
Fixes #4223.
Adds the missing parentheses in the `PHRASE_POSTCODE` join in
`PostcodeParser.parse()`, so words after a space or dash are kept. Also
adds a parser test for a postcode phrase with a space, which fails on
master and passes with the fix.
Sarah Hoffmann [Tue, 13 Oct 2026 17:28:48 +0000 (19:28 +0200)]
Tighten down AI usage policy (#4220)
As announced in #4207, I'm going to take a break from reviewing
AI-generated PRs. This is not a judgement on the overall quality of such
contributions. A good part of them is actually quite usable. The problem
is that it takes a huge amount of time to find out if it is a good or
bad PR. They all look the same on the surface. I'm happy to keep working
with AI-generated content as part of contracting work and when submitted
from long-time contributors, but I'm out of spare time to do this stuff
for drive-by contributions.
The PR also removes the requirement to show a prove of testing. That's
just become useless when AI can easily make up a text section that looks
like a proof.
Sarah Hoffmann [Tue, 13 Oct 2026 07:53:10 +0000 (09:53 +0200)]
add categories for all fallback tags, drop artificial place/house category (#4203)
Fixes #4182.
## Summary
fallback tags such as building and landuse now always get a category,
and all of them are retained if there are more than one. before, only
one (whichever `pairs()` returned last) survived, and only if the object
had a name or address. class/type selection is the same as before.
address only objects still have class/type `place`/`house` but no longer
have `osm.place.house` as a category. `categories` is NULL for those
rows - an empty array would make `is_rankable_place()` drop them. the
backfill in `placex_update()` skips place/house so it doesn't return on
re-index.
adjusted the fallback scenarios in `osm2pgsql/import/tags.feature` and
the two address-only node scenarios in `osm2pgsql/update/tags.feature`
to match.
ran lint, the unit tests and the bdd suites locally, all passed (with
flying colors).
on a full import of the test pbf, all 81 place/house rows in placex now
have NULL categories and none carry osm.place.house.
CI is red because of the sqlalchemy 2.1 thing that #4202 mentioned.
## AI usage
Used Ai for the testing purposes and for extending the existing tests
for this case.
## Summary
While debugging https://github.com/osm-search/Nominatim/issues/4205 with
a local database (added the gate as entrance locally) I discovered
"nominatim lookup" with "--entrances" didn't print the entrance data.
For the examples I'm using [an
entrance](https://www.openstreetmap.org/node/3144704341) of [a swimming
center](https://www.openstreetmap.org/way/309147947).
`nominatim search --query "Piscinas do Sport Lisboa e Benfica" --limit 1
--entrances`
- before: `{"name": "Piscinas do Sport Lisboa e Benfica", "entrances":
[{"osm_id": 3144704341, "type": "yes"}] }`
- after: `{"name": "Piscinas do Sport Lisboa e Benfica", "entrances":
[{"osm_id": 3144704341, "type": "yes"}] }`
`nominatim reverse --lat 38.751207 --lon -9.182630 --entrances`
- before: `{"name": "Piscinas do Sport Lisboa e Benfica", "entrances":
null}`
- after: `{"name": "Piscinas do Sport Lisboa e Benfica", "entrances":
[{"osm_id": 3144704341, "type": "yes"}] }`
`nominatim lookup --id W309147947 --entrances`
- before: `{"name": "Piscinas do Sport Lisboa e Benfica", "entrances":
null}`
- after: `{"name": "Piscinas do Sport Lisboa e Benfica", "entrances":
[{"osm_id": 3144704341, "type": "yes"}] }`
`nominatim details --way 309147947 --entrances`
- before: `{"name": "Piscinas do Sport Lisboa e Benfica"}` //
"entrances" key not in response
- after:`{"name": "Piscinas do Sport Lisboa e Benfica", "entrances":
[{"osm_id": 3144704341, "type": "yes"}]}`
## AI usage
Used for both code and test. Tests iterated several times trying to make
it more readable. All commands in this PR tested manually on two
servers.
Sarah Hoffmann [Tue, 13 Oct 2026 07:28:32 +0000 (09:28 +0200)]
Escape error message text (#4210)
## Summary
I got a HTTP 500 error with
https://nominatim.openstreetmap.org/search?q=berlin&format=xml&include=%3C1
but it turns out it was my app. The Nominatim API returns HTTP 400 with
broken XML which couldn't be parsed.
```
XML Parsing Error: not well-formed
Line Number 4, Column 50
```
Best to escape all error message text.
## AI usage
I did the XML format handling, documentation, manual tests, PR. LLM
added JSON and extended the test.
Sarah Hoffmann [Mon, 12 Oct 2026 08:00:36 +0000 (10:00 +0200)]
Documentation: point to helper script cutting down TIGER data (#4212)
## Summary
Nominatim TIGER import processes every input row and looks for nearby
streets even if the region doesn't have OSM data imported. Importing a
small region of OSM data, then TIGER data can take hours. Instead of
adding more logic/parameters/thing-that-need tests I created a helper
script to cut down the CSV files.
## AI usage
Script mostly LLM generated. Years ago I wrote two versions of the TIGER
data extract in the repo so I understand the input and output data.
Tested with extracts.
Sarah Hoffmann [Mon, 12 Oct 2026 07:59:00 +0000 (09:59 +0200)]
Various updates to CI and adaptions for newer dependency versions (#4218)
This finally fixes all the latest CI fails:
* type adaptions for SQLAlchemy 2.1 (including reallowing this version)
* type adaptions for urllib
* replacement of SQLAlchemy's `await_` (see #4202)
* some general cleanup of the CI scripts including moving linting into
its own task so it will fail quickly when it fails