'Algolia: show location based results within a certain boundary of radii around you

All my items have GeoLocation data stored in algolia.
I want to query items that are between for example 15 and 30 km away.
Atm, I only see an option of specifying a central point and then defining a radius around that point. Meaning I also get results under 15 km away.

    const searchParams = {
      aroundLatLng: `${latitude}, ${longitude}`,
      aroundRadius: 30000,
      facetFilters: [],
      hitsPerPage: MAX_PAGE_SIZE
    }

Maybe something can be done with some geo specific filters (? if that exists)

filters: `distance >= ${15000}`,

How can I query for items that are between the circumferences of two location based circles (in this example inner circle radius: 15000, outer circle radius 30000)



Solution 1:[1]

Algolia's geoSearch capabilities don't currently support complex geometric shapes like rings.

I could think of two ways to accomplish something close to this:

  1. Create the shape using a series of polygons (https://www.algolia.com/doc/guides/managing-results/refine-results/geolocation/how-to/filter-results-inside-a-polygonal-area/)

  2. Perform queries at both the inner and outer radius, then remove and records that appear in both result sets.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Chuck Meyer