You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
We should improve substring searching for our Nominatim #454
Strangely, searching on "Territory" or "Marino" seem to work just fine.
It's almost as if you are allowed to substring search on everything but the first word in the actual name string. Sarah has pointed out that Nominatim prefers full string matching, but I'm not sure how that's tunable. We should be sure to scour the docs.
What should be happening?
Searching for a substring of any name - including the first word in the name - should return all of the matching results.
Could the years at the end of these features’ names be tripping up Nominatim? Many geocoders have difficulty with, for instance, numeric street names, because after tokenization, it becomes unclear whether the number in the query is part of the street name or something else.
Edit: In #455, @lonvia suggests a custom tokenizer to strip out these dates.
The strong preference of full-name matches is hard-coded and cannot be changed without changing the code. The logic goes: if there is a full-name match available, partial matches will not be shown. Usually you can get partial matches by using the button 'More results' but I see you have disabled that one.
If you want to hack around the full-name restriction I recommend you do it in the rails code: check for the number of returned results and if it is too low for your taste, send another request with the more_url that comes with the result.
Looking at the API calls here is interesting... I thought we'd just be able to swap from a "fewer, better results" to a "more, less good results" and have the latter include the former, but it's not clear that's the case.
If you do not want certain OSM objects to appear in the search result, give a comma separated list of the place_ids you want to skip. This can be used to retrieve additional search results. For example, if a previous query only returned a few results, then including those here would cause the search to return other, less accurate, matches (if possible).
So we can easily restore the More Results link by uncommenting those lines. I'll test that tomorrow.
I don't see a way to just force the More Results to show up without the second click with the exclusions that force it to return "less desirable" results.
Under localdev, Nominatim wasn't working for me -- it was hitting OSM Nominatim and returning 404. In my settings.local.yml (which is outside version control) I needed to change line 77nominatim_url: "https://nominatim.openhistoricalmap.org/"
That was easy, and now localdev is hitting nominatim.openhistoricalmap.org but still reporting Error contacting nominatim.openhistoricalmap.org: 404
As a result, I can't test whether simply uncommenting those lines gets us the More Results button back, as a stopgap solution to this issue.
Just to clarify this ticket -- I am not trying to run Nominatim locally. I just want to hit the normal nominatim.openhistoricalmap.org endpoint from the local website.
about Stanford it return 3 results, but not sure why it is not returning Stanford University, maybe need to re-check the config about amenity=university
This has to do with importance. Nominatim considers rivers and streets s more important than a simple POI (which a university is). Clicking on 'Search for more results' and the university should appear. Nominatim uses wikipedia/wikidata tags to determine how well known an object is. This should work just fine for you, given that you seem to be using those tags in your database too. At least Stanford university has one. Make sure you download the importances. If your database is small enough, then you should be able to do the update mentioned in the 'Tip' box in reasonable time.
This discussion showed that the issue was importance ranks, not substring matching. Closing in favor of #1401.
Activity
1ec5 commentedon Sep 22, 2022
Could the years at the end of these features’ names be tripping up Nominatim? Many geocoders have difficulty with, for instance, numeric street names, because after tokenization, it becomes unclear whether the number in the query is part of the street name or something else.
Edit: In #455, @lonvia suggests a custom tokenizer to strip out these dates.
lonvia commentedon Sep 23, 2022
The strong preference of full-name matches is hard-coded and cannot be changed without changing the code. The logic goes: if there is a full-name match available, partial matches will not be shown. Usually you can get partial matches by using the button 'More results' but I see you have disabled that one.
If you want to hack around the full-name restriction I recommend you do it in the rails code: check for the number of returned results and if it is too low for your taste, send another request with the more_url that comes with the result.
danrademacher commentedon Dec 28, 2022
OK, very belated open issue review here. Updates to Nominatim in the fall led to this being much improved:

A search for "san marino" now catches all the things we want: https://www.openhistoricalmap.org/search?query=san%20marino#map=13/43.9425/12.4595&layers=O&date=1922-01-01&daterange=1922-01-01,2022-12-31
jeffreyameyer commentedon May 10, 2023
This issues appears to have reemerged - maybe a missed catch-up item that needs to be added to a checklist?
---> No Oregon Territory in search results:
https://www.openhistoricalmap.org/search?query=oregon#map=7/44.147/-120.520&layers=O&date=1859-11-22&daterange=1846-07-09,2023-12-31
San Marino & a few other test results seem fine...
danrademacher commentedon May 16, 2023
danrademacher commentedon May 16, 2023
The OHM Nominatim link was fixed in OpenHistoricalMap/ohm-website@a753c13
jeffreyameyer commentedon Jul 31, 2023
@Rub21 @batpad - where are we on this ticket? I'm noticing that "Stanford" returns nothing right now, but "Stanford University" returns... Stanford University. : )



https://www.openhistoricalmap.org/search?query=stanford#map=18/14.62698/121.05469&layers=O&date=1923-01-01&daterange=1923-01-01,2023-12-31
https://www.openhistoricalmap.org/search?query=stanford%20university#map=20/37.42749/-122.17026&layers=O&date=1923-01-01&daterange=1923-01-01,2023-12-31
and "Oregon" is back to not returning "Oregon Territory":
https://www.openhistoricalmap.org/search?query=oregon#map=8/44.149/-120.515&layers=O&date=1923-01-01&daterange=1923-01-01,2023-12-31
8 remaining items
danrademacher commentedon Aug 8, 2023
Notes on this:
danrademacher commentedon Aug 9, 2023
Looking at the API calls here is interesting... I thought we'd just be able to swap from a "fewer, better results" to a "more, less good results" and have the latter include the former, but it's not clear that's the case.
If I search for "Oakland" with this plain query string:
https://nominatim.openhistoricalmap.org/search.html?q=oakland
I get three results. The same as if I use this API endpint:
https://nominatim-api.openhistoricalmap.org/search.php?q=oakland&polygon_geojson=1&format=jsonv2
The only difference with More Results is that the first three "best matches" have been excluded:
https://nominatim.openhistoricalmap.org/search.html?q=oakland&exclude_place_ids=149505%2C142380%2C146834
and the API:
https://nominatim-api.openhistoricalmap.org/search.php?q=oakland&polygon_geojson=1&exclude_place_ids=149505%2C142380%2C146834%2C272498%2C1178512%2C1259056%2C1243822%2C1220825%2C847593&format=jsonv2
looking at the API docs, this seems to be the intended behavior:
https://nominatim.org/release-docs/latest/api/Search/#result-limitation
OK, but where is the No Results button?
Here it is in the html.erb:
https://github.com/OpenHistoricalMap/ohm-website/blob/3dbfdf6b39ef261d412ca17bf77ebdfd05c24fa8/app/views/geocoder/results.html.erb#L13-L22
Aha, but it was commented out for some reason... way back in 2021!
https://github.com/OpenHistoricalMap/ohm-website/blame/3dbfdf6b39ef261d412ca17bf77ebdfd05c24fa8/app/controllers/geocoder_controller.rb#L100-L102
So we can easily restore the More Results link by uncommenting those lines. I'll test that tomorrow.
I don't see a way to just force the More Results to show up without the second click with the exclusions that force it to return "less desirable" results.
danrademacher commentedon Aug 9, 2023
Continuing to file this under "nothing is simple"
settings.local.yml(which is outside version control) I needed to change line 77nominatim_url: "https://nominatim.openhistoricalmap.org/"nominatim.openhistoricalmap.orgbut still reportingError contacting nominatim.openhistoricalmap.org: 404As a result, I can't test whether simply uncommenting those lines gets us the More Results button back, as a stopgap solution to this issue.
danrademacher commentedon Aug 12, 2023
@Rub21 could you confirm if when you run the applicaiton locally, a simple Nominatim search returns results?
I get this 404:

I can't quite figure out if this is just an artifact of my installation, or a problem in our localdev generally.
It does make it hard to debug front-end nominatim issues.
danrademacher commentedon Aug 22, 2023
From slack dm:
you can do the following
I ran the aws and kubectl commands and now, on my mac, this link is working:
http://localhost:8080/search.php?q=oakland&polygon_geojson=1&format=jsonv2 [returns same results as that query on Nominatim directly]
this is not
http://host.docker.internal:8080/search.php?q=oakland&polygon_geojson=1&format=jsonv2
but no change in the behavior of the locally running website — still treats Nominatim as 404.
Did Nominatim searching work locally for you with or without doing the above?
Maybe I need to add host.docker.internal:8080 to my Docker configuration somewhere?
danrademacher commentedon Aug 22, 2023
Just to clarify this ticket -- I am not trying to run Nominatim locally. I just want to hit the normal nominatim.openhistoricalmap.org endpoint from the local website.
1ec5 commentedon Jul 15, 2026
This discussion showed that the issue was importance ranks, not substring matching. Closing in favor of #1401.