Searching objects by Geolocation

Radek Kamiński
May 18, 2018

The core part of each booking system is searching for offers (flights, apartments, goods etc.).There is no big deal in it when we think about full-text search (we can find ready solutions for such purpose like ElasticSearch on the market) but when you consider searching by a geolocation (town, city, region, country) of particular object it gets more and more complex.

Challenges

One of the projects we were working on at Nexocode, created a challenge for us. The geolocation search engine we were working on had requirements like multilingual processing, accuracy plus neighboring locations and high speed.

We reviewed available solutions but the trickiest part - the accuracy of results was left unaddressed. One option we considered and quickly abandoned was searching by radius from the center of a given location. This solution is pretty good for small symmetric locations but it gives you low accuracy for bigger, irregular shapes. The second option was to search in a full-text manner cause we already had objects’ addresses. The problem here was that addresses were in majority in English so we couldn’t satisfy non-English users. The last option we came up with was related to pre-processing objects based on location boundaries. That was the option we’ve chosen and it has given us very good results.

Location Polygons

Polygon-based search by geolocation

What have we done? We’ve taken 3rd party DB of boundaries (polygons) with their multilingual names assigned to unique identifiers and we pre-processed data by assigning one or more identifiers per object based on object location. Knowing object longitude and latitude you can simply calculate whether the object is within a given polygon or not.

Additionally, we used the same DB to let user select input criteria based on location multilingual names and read its identifier. Thanks to that, we could transmit particular location identifier, rather than the center point or location name, in the search request.

Extended search with neighboring locations

With the approach we designed, we could easily extend this mechanism by additional features like “neighboring locations” so any time user requested particular location, the service was able to recommend neighboring locations in case of lacking results in the basic location.

Neighboring Location
The rest was very easy. Searching through indexed identifiers is highly efficient. Accuracy depends on polygons definitions: the better data source you use the better result you get.

Conclusion

Data preprocessing is a crucial part of all searching mechanisms. Having data aggregated and tailored to your needs gives you performance and flexibility in building new features.

Now, let's talk about your project!

We don't have one standard offer.
Each project is unique, rest assured that we will approach the next one full of energy and engagement.

LET'S CONNECT