public class GeoNearOperation extends Object implements AggregationOperation
geoNear aggregation operation.
We recommend to use the static factory method Aggregation.geoNear(NearQuery, String) instead of creating
instances of this class directly.
| Constructor and Description |
|---|
GeoNearOperation(NearQuery nearQuery,
String distanceField)
Creates a new
GeoNearOperation from the given NearQuery and the given distance field. |
| Modifier and Type | Method and Description |
|---|---|
String |
getOperator()
Return the MongoDB operator that is used for this
AggregationOperation. |
org.bson.Document |
toDocument(AggregationOperationContext context)
|
List<org.bson.Document> |
toPipelineStages(AggregationOperationContext context)
|
GeoNearOperation |
useIndex(String key)
Optionally specify the geospatial index to use via the field to use in the calculation.
|
public GeoNearOperation(NearQuery nearQuery, String distanceField)
GeoNearOperation from the given NearQuery and the given distance field. The
distanceField defines output field that contains the calculated distance.nearQuery - must not be null.distanceField - must not be null.public GeoNearOperation useIndex(String key)
key - the geospatial index field to use when calculating the distance.GeoNearOperation.public org.bson.Document toDocument(AggregationOperationContext context)
AggregationOperationtoDocument in interface AggregationOperationcontext - the AggregationOperationContext to operate within. Must not be null.public String getOperator()
AggregationOperationAggregationOperation. Aggregation operations should
implement this method to avoid document rendering.getOperator in interface AggregationOperationAggregationOperation.public List<org.bson.Document> toPipelineStages(AggregationOperationContext context)
AggregationOperationAggregationOperation into list of stages by using the given
AggregationOperationContext. This allows a single AggregationOptions to add additional stages for
eg. $sort or $limit.toPipelineStages in interface AggregationOperationcontext - the AggregationOperationContext to operate within. Must not be null.Copyright © 2011–2022 Pivotal Software, Inc.. All rights reserved.