How to Find Items Near a Point and Score Them By How Far Each Item is from Another Point

Frequently there is a need to find something with a specific radius. In that case, the engine automatically scores each item by how close it is to the point.

That query criterion would look something like this:

{
 criteria: [
  {
   // radius of 10 mi for exact match tagging
   // relevance score is set depending on how far each item is
   // from the specified point
   dimension: 'geoloc',
   longitude: -71,
   latitude: 40,
   exactDistance: 10,
  }
 ]
}

If you want to find everything within a certain radius, say the geocentroid of a town or city but determine their relevance by distance from another point, you can use this query construct:

{
 criteria: [
  {
   // radius of 10 mi for exact match tagging
   dimension: 'geoloc',
   longitude: -71,
   latitude: 40,
   exactDistance: 10,
   // causes this query not to impact relevance at all, just whether the item is
   // an exact match or not
   weight: 0
  },
  {
   // This is point that determines relevance scoring
   dimension: 'geoloc',
   longitude: -71,
   latitude: 40,
   // for exact match to true for this criterion since all we want is the
   // relevance calculation
   exactMatch: true
  }
 ]
}