Package dev.morphia.aggregation.stages
Class GeoNear
java.lang.Object
dev.morphia.aggregation.stages.Stage
dev.morphia.aggregation.stages.GeoNear
Outputs documents in order of nearest to farthest from a specified point.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiondistanceField
(String distanceField) The output field that contains the calculated distance.distanceMultiplier
(Number distanceMultiplier) Optional.static GeoNear
geoNear
(double[] coordinates) Creates a new geoNear stagestatic GeoNear
Creates a new geoNear stagestatic GeoNear
Creates a new geoNear stageincludeLocs
(String includeLocs) Optional.Optional.maxDistance
(Number maxDistance) Optional.minDistance
(Number minDistance) Optional.Optional.Optional.
-
Constructor Details
-
GeoNear
-
-
Method Details
-
geoNear
Creates a new geoNear stage- Parameters:
variable
- the variable to use as a reference- Returns:
- the new stage
- Since:
- 3.0
- MongoDB documentation
- Aggregration Pipeline Stage: $geoNear
-
geoNear
Creates a new geoNear stage- Parameters:
point
- the center point- Returns:
- the new stage
- Since:
- 2.2
- MongoDB documentation
- Aggregration Pipeline Stage: $geoNear
-
geoNear
Creates a new geoNear stage- Parameters:
coordinates
- the center point coordinates- Returns:
- the new stage
- Since:
- 2.2
- MongoDB documentation
- Aggregration Pipeline Stage: $geoNear
-
distanceField
The output field that contains the calculated distance.- Parameters:
distanceField
- the field name- Returns:
- this
-
distanceMultiplier
Optional. The factor to multiply all distances returned by the query. For example, use the distanceMultiplier to convert radians, as returned by a spherical query, to kilometers by multiplying by the radius of the Earth.- Parameters:
distanceMultiplier
- the multiplier- Returns:
- this
-
getVariable
-
includeLocs
Optional. This specifies the output field that identifies the location used to calculate the distance. This option is useful when a location field contains multiple locations.- Parameters:
includeLocs
- include the field if true- Returns:
- this
-
key
Optional. Specify the geospatial indexed field to use when calculating the distance.- Parameters:
key
- the indexed field- Returns:
- this
-
maxDistance
Optional. The maximum distance from the center point that the documents can be. MongoDB limits the results to those documents that fall within the specified distance from the center point.Specify the distance in meters if the specified point is GeoJSON and in radians if the specified point is legacy coordinate pairs.
- Parameters:
maxDistance
- the max distance- Returns:
- this
-
minDistance
Optional. The minimum distance from the center point that the documents can be. MongoDB limits the results to those documents that fall outside the specified distance from the center point.Specify the distance in meters for GeoJSON data and in radians for legacy coordinate pairs.
- Parameters:
minDistance
- the min distance- Returns:
- this
-
query
Optional. Limits the results to the documents that match the query.You cannot specify a $near predicate in the query field of the $geoNear stage.
- Parameters:
filters
- the filters to apply- Returns:
- this
-
spherical
Optional. Determines how MongoDB calculates the distance between two points:- When true, MongoDB uses $nearSphere semantics and calculates distances using spherical geometry.
- When false, MongoDB uses $near semantics: spherical geometry for 2dsphere indexes and planar geometry for 2d indexes.
- Parameters:
spherical
- true if spherical- Returns:
- this
-