So I'm trying to retrieve entries based on their location/coordinates, within a given radius. And have been successful using this :
$query = new \Contentful\Delivery\Query;
$query->setContentType('store')
->where('fields.location[within]', '-37, 144, 50');
However, the order in which they are returned aren't ordered by their distance to the given centre of the radius. Any help please? Thanks.
The within
operator doesn't do any sorting, unlike the near
operator. If you're trying to use within
in the context of a circular area, which seems to be what you're doing, you can replace it with near
and it should work the way you want it:
fields.foo[near]=x,y,radius
The radius
parameter can be used to limit the search area. Give it a try, let me know if this helps!
Davide