[GIS] Location names autocomplete service with custom Nominatim installation

geocodingnominatim

I'm looking to host an autocomplete service. I have installed Nominatim and imported the planet file with Nominatim. It took about 3 days to dump data into database and an additional 7 days to run indexes on an Amazon EC2 extra large instance without any database tuning.

The problem with Nominatim, is that it is designed to parse a complete address and not isolated letters. I would like to modify the code to accept what we could call partial queries, i. e. if the map is showing France, and the user types the letter 'p', the first result is "Paris, France".

https://github.com/twain47/Nominatim/blob/master/lib/Geocode.php#L343

I'm looking for advice from someone who has attempted this before in order to avoid diving into 1500 lines of code and hitting a snag.

Geocoding on my installation is not performing well even without type ahead, and I don't know if it will be possible to host a decent service.

I found this library https://github.com/komoot/photon which seems to work fast enough, but it doesn't seem to include a bounding box as a parameter to the search. I would like this service to work as good as possible with existing Open Source tools and without a third party hosting service.

Is typeahead achievable using available libraries and data, with a small effort, let's say 80 hours of coding/investigation?

Best Answer

Search-as-you-type is not possible in nominatim by design. It goes for exact matches of the search terms.

Photon is based on Apache Solr which provides a built-in spatial support. Little effort should be needed to enhance photon to provide a location bias. The basic idea is to rank the search results by distance to the bounding box.

I am the main contributor of photon and can assist you and guide you through the manuals, feel free to contact me: christoph[°]komoot.de