Class GeoNear

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  GeoNear.GeoNearBuilder
      Provides a builder for GeoNear instances.
    • Method Detail

      • builder

        public static GeoNear.GeoNearBuilder builder​(java.lang.String distanceField)
        Creates a builder for a GeoNear pipeline stage
        distanceField - the field to process
        the GeoNearBuilder
      • getDistanceField

        public java.lang.String getDistanceField()
        the distance field used in this stage
      • getDistanceMultiplier

        public java.lang.Double getDistanceMultiplier()
        the distance multiplier used in this stage
      • getIncludeLocations

        public java.lang.String getIncludeLocations()
        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.
        the field
      • getLimit

        public java.lang.Long getLimit()
        the maximum number of documents to return
      • getMaxDistance

        public java.lang.Double getMaxDistance()
        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.
        the maximum
      • getMaxDocuments

        public java.lang.Long getMaxDocuments()
        The num option provides the same function as the limit option. Both define the maximum number of documents to return. If both options are included, the num value overrides the limit value.
        the maximum
      • getNear

        public double[] getNear()
        The point for which to find the closest documents.

        If using a 2dsphere index, you can specify the point as either a GeoJSON point or legacy coordinate pair.

        If using a 2d index, specify the point as a legacy coordinate pair.

        the point
      • getQuery

        public Query getQuery()
        Limits the results to the documents that match the query.
        the query
      • getSpherical

        public java.lang.Boolean getSpherical()
        Required if using a 2dsphere index. Determines how MongoDB calculates the distance. The default value is false.

        If true, then MongoDB uses spherical geometry to calculate distances in meters if the specified (near) point is a GeoJSON point and in radians if the specified (near) point is a legacy coordinate pair.

        If false, then MongoDB uses 2d planar geometry to calculate distance between points.

        If using a 2dsphere index, spherical must be true.

        true if using spherical geometry
      • getUniqueDocuments

        public java.lang.Boolean getUniqueDocuments()
        since version MongoDB 2.6: Geospatial queries no longer return duplicate results. The $uniqueDocs operator has no impact on results.
        If this value is true, the query returns a matching document once, even if more than one of the document's location fields match the query.
        true if returning only unique documents