Is it possible to index Polygon into _geoloc?

HI Algollia, good day~!

Hope you could assist me on the following:

QUESTIONS

  • Is it possible to index polygon into _geoloc?
  • or Could you suggest a method to achieve the desired result?

USE CASE EXAMPLE:
to allow companies to advertise their services through one of these options:
(1) statewide coverage (where I hope to index polygon into _geoloc)
(2) area wide coverage - areas are within the state of (1)

If say, the state has 40 areas, by choosing option (1), companies with state wide coverage do not have to post the same advert 40 times OR enter 40 locations.

DESIRED RESULT:
When customers do a search, the desired result would show:
area wide coverage companies within proximities of the customer’s location PLUS companies with state wide coverage.

WHAT I HAVE TRIED BUT FAILED TO GET THE DESIRED RESULT:
aroundRadius
when customer do a search within 10 miles radius of his/her current location in area 1, company with statewide coverage won’t show up if it is physically in area 40 which is 100 of miles away.

insidePolygon
all companies (including those beyond 10 miles radius) would show up in the result.

Hi @hwgz01,

In the Algolia record you include the _geoloc latitude and longitude of a single point. You can then use insidePolygon to search for records with a _geoloc that fall inside that larger polygon, however you would not index that polygon in the record itself.

Consider thinking about your desired result as two separate searches:

  • Search 1: “area wide coverage companies within proximities of the customer’s location” > achieve this with aroundRadius or aroundLatLngViaIP
  • Search 2: “companies with state wide coverage” > achieve this with a second search that filters on an additional attribute such as stateWide: true

This will indeed have two separate search results which it is now upto you how to display on the frontend. Two separate sections? Two side-by-side columns? I hope this helps.

HI @ajay.david

Thank you so much for your suggestion~!

I will consider it with the account of front end display and costs involved (as this method doubles the search operations).

but this may be my only option to get the desired result.

1 Like