Skip to main content
In this tutorial, you’ll see how to can filter results inside a rectangular area. This location can either be set manually or taken from the current user position. To run the code examples on this page, install the latest API client.

Dataset

The guide uses a dataset of the 3,000+ biggest airports in the world.
JSON
To tell Algolia where each record is located, the latitude and longitude must be stored in the _geoloc attribute.

Initialize the client

  1. Download the data set
  2. Set up an API client and send your data to Algolia

Configure index settings

Even if you just want to sort by distance to a location, your textual relevance should also be good so that users can refine the search with a query. To do that, you must configure the . The searchable attributes are: name, city, country, and iata_code.

Filtering inside a rectangle area

The USA can be considered as a polygon: Screenshot of a map showing a red rectangular selection box over the United States, with 'États-Unis' labeled inside the box. To filter inside this rectangle, you need to pass the upper-left and bottom-right latitude and longitude to the insideBoundingBox parameter:
  • 49.067996905313834, 65.73828125
  • 25.905859247243498, 128.8046875
The empty query ('') returns all matching airports.
Last modified on May 19, 2026