Algolia's latest articles, right in your inbox.

Pick up the topics you are the most interested in, we take care of the rest!

Thank you for subscribing, stay tuned!

Loading amazing content . . .

Share on facebookShare on linkedinShare on twitterShare by email

Geo-search is playing an important role in user experience, especially on mobile applications. Therefore we’ve never stopped challenging it and we are excited today to announce a big improvement!

This new geo-search release simplifies most of the use cases, adds several features, and maintains backward-compatibility! And because we are hardcore when it comes to performance, we’ve made sure this update won’t impact anything. Better yet, all queries will actually be faster!

 

auto-radius

The end of the radius pain!

The most used geo-search feature was the retrieval of records around a specific geolocation. It is widely used by mobile applications via the device’s GPS position. On browsers, you can use our IP based geolocation feature. This feature requires a maximum distance called “radius” to perform the search, which was set by default to 10km. Because radius has an impact on performance, it is important to keep it low. In reality, it may become extremely cumbersome for our users to set it as the radius would depend on the area’s information density!

Fortunately, we have removed this pain in our new geo-search! While you can still manually define the radius, you can now let the system adjust it according to the density of the area for you … without doing anything! Just leave the aroundRadius query parameter unset! The radius will adapt itself to collect a few thousand records. Its value will also be returned in the result set (in the automaticRadius attribute). This information can help you display your map at the best scale. If you want to have a minimum radius size, we also introduced a query parameter called minimumAroundRadius that configures the minimum value that can be accepted as a radius.

We hope this new feature will help you and will make it super easy to have a good geo-search!

 

multi-geo

Several geolocations per record

Our previous geo-search was limited to only one geolocation per record. No more! Our new version now supports an arbitrary number of geolocations per record. You have just to use an array syntax.

Example of a record with one geolocation:


{
    "title": "Example",
    "_geoloc": { "lat": 47.279430, "lng": 5.106450 }
}

Example of a record with several geolocations:


{
    "title": "Example",
    "_geoloc": [
        { "lat": 47.279430, "lng": 5.106450 },
        { "lat": 47.293228, "lng": 5.004570 },
        { "lat": 47.316669, "lng": 5.016670 }
    ]
}

If your records contain several geolocations, you will be able to retrieve the matched geolocation and the distance in meters by requesting the ranking information (getRankingInfo=true query parameter).

Here is an example of a hit with several geolocations:


{
    "title": "Example",
    "objectID": "20",
    [...]
    "_rankingInfo": {
        [...]
        "matchedGeoLocation": {
            "lat": 47.316669,
            "lng": 5.016670,
            "distance": 1257
        }
    }
}

 

polygon-or

New ways to filter

In the past months, we have received several requests to improve the number of operators supported to filter by geolocation. We were only supporting filtering by a bounding box but we are now excited to offer three new types of filtering!

  • Filter by a polygon (defined by a list of point), you can look at the documentation of the insidePolygon query parameter
  • Filter by a OR between several bounding boxes, you have just to pass several times the insideBoundingBox query parameter
  • Filter by a OR between several polygons, you have just to pass several times the insidePolygon query parameter

We need your feedback!

We see an increasing number of users having geo-search needs, especially on mobile. We hope you will like this big evolution of our geo-search feature and that it will simplify your life! We would love to have your feedback and ideas on how to improve it, feel free to contact us anytime!

Get started with our tutorial

About the author

Loading amazing content . . .