public final class NearQuery extends Object
Modifier and Type | Method and Description |
---|---|
NearQuery |
distanceMultiplier(double distanceMultiplier)
Configures a
CustomMetric with the given multiplier. |
Distance |
getMaxDistance()
Returns the maximum
Distance . |
Metric |
getMetric()
Returns the
Metric underlying the actual query. |
Distance |
getMinDistance()
Returns the maximum
Distance . |
Long |
getSkip() |
NearQuery |
in(Metric metric)
Will cause the results' distances being returned in the given metric.
|
NearQuery |
inKilometers()
Will cause the results' distances being returned in kilometers.
|
NearQuery |
inMiles()
Will cause the results' distances being returned in miles.
|
boolean |
isSpherical()
Returns whether spharical values will be returned.
|
NearQuery |
maxDistance(Distance distance)
Sets the maximum distance to the given
Distance . |
NearQuery |
maxDistance(double maxDistance)
Sets the max distance results shall have from the configured origin.
|
NearQuery |
maxDistance(double maxDistance,
Metric metric)
Sets the maximum distance supplied in a given metric.
|
NearQuery |
minDistance(Distance distance)
Sets the minimum distance to the given
Distance . |
NearQuery |
minDistance(double minDistance)
Sets the minimum distance results shall have from the configured origin.
|
NearQuery |
minDistance(double minDistance,
Metric metric)
Sets the minimum distance supplied in a given metric.
|
static NearQuery |
near(double x,
double y)
Creates a new
NearQuery starting near the given coordinates. |
static NearQuery |
near(double x,
double y,
Metric metric)
|
static NearQuery |
near(Point point)
|
static NearQuery |
near(Point point,
Metric metric)
|
NearQuery |
num(long num)
Configures the maximum number of results to return.
|
NearQuery |
query(Query query)
Adds an actual query to the
NearQuery to restrict the objects considered for the actual near operation. |
NearQuery |
skip(long skip)
Configures the number of results to skip.
|
NearQuery |
spherical(boolean spherical)
Configures whether to return spherical values for the actual distance.
|
org.bson.Document |
toDocument()
Returns the
Document built by the NearQuery . |
NearQuery |
with(Pageable pageable)
Configures the
Pageable to use. |
public static NearQuery near(double x, double y)
NearQuery
starting near the given coordinates.x
- y
- public static NearQuery near(double x, double y, Metric metric)
NearQuery
starting at the given coordinates using the given Metric
to adapt given
values to further configuration. E.g. setting a maxDistance(double)
will be interpreted as a value of the
initially set Metric
.x
- y
- metric
- must not be null.public static NearQuery near(Point point, Metric metric)
NearQuery
starting near the given Point
using the given Metric
to adapt given
values to further configuration. E.g. setting a maxDistance(double)
will be interpreted as a value of the
initially set Metric
.point
- must not be null.metric
- must not be null.public Metric getMetric()
Metric
underlying the actual query. If no metric was set explicitly Metrics.NEUTRAL
will be returned.public NearQuery num(long num)
num
- public NearQuery skip(long skip)
skip
- public NearQuery with(Pageable pageable)
Pageable
to use.pageable
- must not be nullpublic NearQuery maxDistance(double maxDistance)
Metric
was set before the given
value will be interpreted as being a value in that metric. E.g.
NearQuery query = near(10.0, 20.0, Metrics.KILOMETERS).maxDistance(150);Will set the maximum distance to 150 kilometers.
maxDistance
- public NearQuery maxDistance(double maxDistance, Metric metric)
Metric
if one was configured before.maxDistance
- metric
- must not be null.public NearQuery maxDistance(Distance distance)
Distance
. Will set the returned Metric
to be the one of the
given Distance
if Metric
was Metrics.NEUTRAL
before.distance
- must not be null.public NearQuery minDistance(double minDistance)
Metric
was set before the
given value will be interpreted as being a value in that metric. E.g.
NearQuery query = near(10.0, 20.0, Metrics.KILOMETERS).minDistance(150);Will set the minimum distance to 150 kilometers.
minDistance
- public NearQuery minDistance(double minDistance, Metric metric)
Metric
if one was configured before.minDistance
- metric
- must not be null.public NearQuery minDistance(Distance distance)
Distance
. Will set the returned Metric
to be the one of the
given Distance
if no Metric
was set before.distance
- must not be null.@Nullable public Distance getMinDistance()
Distance
.public NearQuery distanceMultiplier(double distanceMultiplier)
CustomMetric
with the given multiplier.distanceMultiplier
- public NearQuery spherical(boolean spherical)
spherical
- public boolean isSpherical()
public NearQuery inKilometers()
distanceMultiplier(double)
and
spherical(boolean)
accordingly.public NearQuery inMiles()
distanceMultiplier(double)
and
spherical(boolean)
accordingly.public NearQuery in(@Nullable Metric metric)
distanceMultiplier(double)
accordingly as well as spherical(boolean)
if the given Metric
is not Metrics.NEUTRAL
.metric
- the metric the results shall be returned in. Uses Metrics.NEUTRAL
if null is
passed.public NearQuery query(Query query)
NearQuery
to restrict the objects considered for the actual near operation.query
- must not be null.public org.bson.Document toDocument()
Document
built by the NearQuery
.Copyright © 2011–2019 Pivotal Software, Inc.. All rights reserved.