geo:dist Geolocation Function - AFS

AFS Integration Guide

Product
AFS
AFS_Version
7.7
Category
Reference Guide

geo:dist is a geolocation function, capable of comparing the real-world geographic location of a result with the location of a particular given place.

Results must have at least two facets values, one for latitude and one for longitude. A result can have as many geolocation points as desired (such as results for a concert which takes place in several cities).

These values are in decimal degrees. See Decimal Degrees (Wikipedia) for more information. The World Geodetic System used is WGS 84. See World Geodetic System (Wikipedia) for more information.

For more information about configuring these two necessary facets, see Geolocation Facet for geo:dist Function part of the AFS v7.7 Configuration Guide.

Within the query, the coordinates of the particular place is given in decimal degrees.

geo:dist(place_latitude,place_longitude)

Then the function calculate, for every result, its distance from the particular place.

It is then possible to filter results, for example this query returns only results for foobar in a 25-km radius of the given coordinates:

...afs:query=foobar&afs:filter=geo:dist(48.85341000,2.34880000)<25000&...

It is also possible to sort results by distance, for example this query returns results close to foobar, sorted from the farthest to the nearest point:

...afs:query=foobar&afs:sort=geo:dist(place_latitude,place_longitude>),ASC

If geolocation facets have not been configured using default names (geo:lat and geo:long), the following syntax must be used:

geo:dist(place_latitude,place_longitude,latitude_facet_name,longitude_facet_name)