openstreetmap / openstreetmap-website

The Rails application that powers OpenStreetMap
https://www.openstreetmap.org/
GNU General Public License v2.0
2.2k stars 911 forks source link

API: note search shouldn't be sensitive to accents #2585

Open tuxayo opened 4 years ago

tuxayo commented 4 years ago

When I search for "caméra" or "camera" I get different results.

https://api.openstreetmap.org/api/0.6/notes/search?q=cam%C3%A9ra

https://api.openstreetmap.org/api/0.6/notes/search?q=camera

Related source code: https://github.com/openstreetmap/openstreetmap-website/blob/8199002a0fd83a6eec91764bcec9e9e8705c7e5d/app/controllers/api/notes_controller.rb#L277

Downsteam issue: https://github.com/ENT8R/NotesReview/issues/46

tomhughes commented 4 years ago

Well as you have observed the search is very simple and it just passes the work of to postgres so unless you have some suggestions as to how to make that do what you want there isn't much we can do.

Generally speaking using the API for search is a bad idea and you're usually better off using third party services which specialise in that - we should probably get rid of all the search endpoints really.

tuxayo commented 4 years ago

Thanks for the analysis. Your are making good points, I'll pass the message downstream.

In the event going toward supporting this in the API would the unaccent extension be a solution? There is also the "Poor man's solution" (creating a FUNCTION that does this) Both are detailed here:

https://stackoverflow.com/questions/9243322/postgres-accent-insensitive-like-search-in-rails-3-1-on-heroku

tomhughes commented 4 years ago

Oh there are ways of attacking the problem, but they are major projects requiring reindexing of the production database, not simple tweaks.

The question is how much effort do we want to expend on fixing something that we're really looking to retire in the long term.