osm-search / Nominatim

Open Source search based on OpenStreetMap data
https://nominatim.org
GNU General Public License v3.0
3.12k stars 713 forks source link

Structured search with a street that does not exist but a city/postal code that exist gives the wrong city #3355

Closed SpaghettiBolognaise closed 6 months ago

SpaghettiBolognaise commented 7 months ago

What did you search for?

41 RUE DU 11 NOVEMBRE 1918, 62150 LA COMTÉ (France)

What result did you get?

I get : Rue du 11 Novembre 1918, La Fontaine, Villeneuve-sur-Yonne, Sens, Yonne, Bourgogne-Franche-Comté, France métropolitaine, 89500, France which is located approx. 270km away.

What result did you expect?

The actual location is 50.42554335064338, 2.4949411016785232, 41 Rue du onze novembre 62150 la Comté. But the expected result is the town La Comté, because the street "Rue du 11 Novembre 1918" does not exist in this town.

There are two issues:

One on our side which is the automated system that changed the customer input "rue du onze novembre" to "Rue du 11 novembre 1918", we are working to fix that

The other issue is that, while the street does not exist, the postal code is still correct. Why is Nominatim not giving the coordinates to the town La Comté instead of giving a location with a different (but similar) street name and a completely different postal code ? It should prioritize the postal code. (Can we configure that ? We use the mediagis/nominatim-docker docker image)

We think it may be a issue with the fact that the administrative division, in the wrong result, is named "Bourgogne-Franche-Comté", which contains "Comté" like the town, despite the fact the name of the town is explicitly passed to the "city" parameter. When doing the search with a town that has the same postal code, we get no results: 41 RUE DU 11 NOVEMBRE 1918, 62150 BAJUS (France)

Thanks for having a look.

lonvia commented 7 months ago

There are a couple of issues to untangle here:

Regarding the postcode: Nominatim explicitly remains fuzzy around postcodes because the input OSM data is rather vague on them and postcodes on many features are rather the result of an educated guess. You can't really force it to prioritize on the postcode. And it won't fall back to a town when it can't find the street. You need to do this yourself by repeating the query with less input.

For "once" vs. "11" there is the very, very old issue #298. One of these days Nominatim will be able to handle this.

This leaves the odd matching of "La Compté" against "La Fontaine, Bourgogne-Franche-Compté". Nominatim doesn't use the field types of the structured search during the lookup. The search index doesn't support that. That leaves only rematching against the results that are found. Currently it would only change the order of the results returned. In a case like this, where we'd rather expect no result to be returned, it wouldn't help. We'd need to start dropping results because they don't match. Worth thinking about how to do that without dropping good results.

This case is also somewhat related to #3275. It's not a structured search but, still, there is a match of what is supposed to be a single name consisting of multiple words against single words from multiple names.

SpaghettiBolognaise commented 7 months ago

Thanks for the investigation. We'll retry the query without the street if the postcode of the result does not match, that should work for most cases.