Contentful logo

Contentful Community

Querying based on geoposition calculation?

Hey guys, Contentful noob here.

I note that Contentful supports geoposition (lat/lng) fields. What’s the best way to query these fields given that you’d normally want to run calculations on them, to establish which items in a store were relevant (proximate) to a user’s position? If I were doing this with a backend and database that I controlled, I’d submit the user’s geoposition to the server, and use that in calculations in my SQL to determine which records to return.

I asked Contentful support but since I’m on the free plan they wouldn’t help, but did say that running calculations while querying wasn’t supported.

Obviously I could retrieve all records and do the calculations in my app, but that would be really inefficient where a store has thousands of rows.

Thanks!

It seems Contentful’s support was not exactly selling the platform to me, as this turns out to be very easy thanks to the Location Proximity Search functionality of the Content Delivery API. In case this helps anyone else with the same question, here’s the ref:

https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters/location-proximity-search

1 Like