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
        Parameters:
        distanceField - the field to process
        Returns:
        the GeoNearBuilder
      • getDistanceField

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

        public java.lang.Double getDistanceMultiplier()
        Returns:
        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.
        Returns:
        the field
      • getLimit

        public java.lang.Long getLimit()
        Returns:
        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.
        Returns:
        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.
        Returns:
        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.

        Returns:
        the point
      • getQuery

        public Query getQuery()
        Limits the results to the documents that match the query.
        Returns:
        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.

        Returns:
        true if using spherical geometry
      • getUniqueDocuments

        @Deprecated
        public java.lang.Boolean getUniqueDocuments()
        Deprecated.
        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.
        Returns:
        true if returning only unique documents