Skip to content

Improve searchability of postcodes with optional spaces and dashes - #1105

Merged
lonvia merged 3 commits into
komoot:masterfrom
lonvia:postcode-alternative
Aug 7, 2026
Merged

Improve searchability of postcodes with optional spaces and dashes#1105
lonvia merged 3 commits into
komoot:masterfrom
lonvia:postcode-alternative

Conversation

@lonvia

@lonvia lonvia commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Two changes so that postcodes containing spaces or dashes are also searchable when omitting spaces/dashes:

  • The code exporting the postcode table now adds the space-omitting version of the postcode as an alternative name.
  • When building the search index, the space-omitting version of the postcode is added to the basic token index so that it is findable. Furthermore, the reranking also checks the query against the space-omitting version.

There is one more change to the Nominatim export to make that work properly: postcodes for places are now always taken from the postcode column. The value of addr:postcode is ignored. That's done because postcode is guaranteed to contain a valid, normalized version of the postcode with spaces intact while mapping of postcodes in OSM varies.

Please note that there are a few countries where Nominatim works with the postcode without spaces, for example in India. If you want a Photon database which supports both versions, you need to change the postcode output in Nominatim's country settings. The Graphhopper exports work with the standard postcode settings

lonvia added 3 commits August 7, 2026 09:56
The field provides properly formatted postcodes and drops the ones
that do not comply to the country's format. That should lead to better
results.
@lonvia
lonvia merged commit 5f15e96 into komoot:master Aug 7, 2026
5 checks passed
@lonvia
lonvia deleted the postcode-alternative branch August 7, 2026 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant