发布于 2015-09-14 15:02:04 | 232 次阅读 | 评论: 0 | 来源: 网络整理
-
geoNear
The geoNear command provides an alternative to the
:operator :$near operator. In addition to the
functionality of $near, geoNear returns the distance of
each item from the specified point along with additional diagnostic
information. For example:
{ geoNear : "places" , near : [50,50], num : 10 }
Here, geoNear returns the 10 items nearest to the
coordinates [50,50] in the collection named
places. geoNear provides the following options (specify all
distances in the same units as the document coordinate system:)
Fields: |
- near – Takes the coordinates (e.g. [ x, y ]) to use as
the center of a geospatial query.
- num – Optional. Specifies the maximum number of documents to
return. The default value is 100.
- maxDistance – Optional. Limits the results to those falling within
a given distance of the center coordinate.
- query – Optional. Further narrows the results using any standard
MongoDB query operator or selection. See db.collection.find()
and “查询,更新, 以及投影算符快速参考” for more
information.
- spherical – Optional. Default: false. When true
MongoDB will return the query as if the
coordinate system references points on a
spherical plane rather than a plane.
- distanceMultiplier – Optional. Specifies a factor to multiply
all distances returned by
geoNear. For example, use
distanceMultiplier to convert from
spherical queries returned in radians to
linear units (i.e. miles or kilometers)
by multiplying by the radius of the
Earth.
- includeLocs – Optional. Default: false. When specified
true, the query will return the location of
the matching documents in the result.
- uniqueDocs – Optional. Default true. The default settings
will only return a matching document once, even
if more than one of its location fields match
the query. When false the query will return
documents with multiple matching location fields
more than once. See $uniqueDocs for
more information on this option
|