Repository navigation
Description
Search results from the Nominatim API currently do not indicate start and end dates according to the element’s start_date=* and end_date=* tags.
Steps to reproduce
This Nominatim search for “Loveland” includes this result. The extratags object looks like this:
{
"wikidata": "Q843993",
"wikipedia": "en:Loveland, Ohio",
"name:etymology": "James Loveland",
"name:etymology:wikidata": "Q8308802"
}even though the node is tagged start_date=1876-05-16 and end_date=1961-07-25.
Impact
The dates are important information for disambiguating search results (#431) without needing to hard-code date ranges in the name=* tag (related to #793). These tags would also be necessary for automatically adjusting the time slider when selecting a feature from the search results list (#196). One idea for searching by date would rely on filtering results by date on the client side – this would also require exposing the date tags.
Diagnosis
The API’s JSON response format includes an extratags property that serves as a catch-all for miscellaneous tags that the client can read without having to send a separate OSM API request or Overpass API query. ohm-website is already setting extratags=1 in its Nominatim requests, but by default, Nominatim is only including certain keys that are common in OSM, such as ele=*, population=*, and wikidata=*.
Based on this documentation, we can include the date tags by providing a custom import style. We’d copy import-full.lua to the project directory, then set the NOMINATIM_IMPORT_STYLE variable to the Lua script’s file path, either in a .env file or as an environment variable. The Lua script needs to have something like this in it:
flex.set_prefilters {
-- Source tags are very common but not used by Nominatim. Deleting them speeds up indexing.
delete_keys = {'source', 'source:*', '*:source'},
-- Date tags are essential for disambiguation.
extra_keys = {'start_date', 'start_date:edtf', 'end_date', 'end_date:edtf'}
}Metadata
Metadata
Assignees
Type
Projects
- StatusShow more project fieldsIn Production
Activity
1ec5 commentedon Feb 7, 2025
The
NOMINATIM_IMPORT_STYLEenvironment variable needs to be set in this template:https://github.com/OpenHistoricalMap/ohm-deploy/blob/5b72c8213524801edf39c666c0fdb13dd997e0c5/values.production.template.yaml#L664
which parallels an example environment file in osm-seed:
https://github.com/developmentseed/osm-seed/blob/49245d21c7ef9a9314c63397914d71f1b5fd235d/envs/.env.nominatim.example
Rub21 commentedon Feb 7, 2025
which would be the value for
NOMINATIM_IMPORT_STYLE, I can add in the configuration and tested in staging, also we are using nominatimmediagis/nominatim:4.1https://github.com/developmentseed/osm-seed/blob/49245d21c7ef9a9314c63397914d71f1b5fd235d/images/nominatim/Dockerfile#L1 ,there are more recent versions for nominatim , https://hub.docker.com/r/mediagis/nominatim/tags
1ec5 commentedon Feb 7, 2025
The import style mechanism was the same in v4.1, but that version used a different .style format:
{ "keys" : ["start_date", "start_date:edtf", "end_date", "end_date:edtf"], "values" : { "" : "extra" } }NOMINATIM_IMPORT_STYLEto the path to this raw file.For a more recent version of Nominatim:
NOMINATIM_IMPORT_STYLEto the path to this raw file.Note that I haven’t tested any of this, so it might need some trial and error.
Rub21 commentedon Feb 17, 2025
I have updated the nominatim to 4.5 in staging, that including the extratags.
Here is the API: https://nominatim-api.staging.openhistoricalmap.org/. There are updates on the front end that still need to be worked on at https://nominatim-staging.openhistoricalmap.org/.
danrademacher commentedon Feb 25, 2025
This is done and deployed. This unblocks #431 most immediately