The DISTSPHERICAL field specifier allows you to find documents in which the values of the LATFIELD and LONGFIELD fields (latitude and longitude, respectively) are within a specified distance from a specified point.


lat The specified latitude. Specify latitude positions south of the equator as negative.
long The specified longitude. Specify longitude positions west of the Greenwich Meridian as negative.
dist The distance in kilometers from the specified latitude and longitude.
LATFIELD The document field containing the latitude.
LONGFIELD The document field containing the longitude.

You must specify two fields, in the order latitude:longitude.


You can optimize the field specifier speed by restricting the latitude and longitude fields to the NumericType property type.



This example matches all documents whose position is within a 20 kilometer radius of San Francisco (37.75N,122.4W). The latitude and longitude position of a document in this example is contained in the fields LAT and LONG, respectively.