Package dev.morphia.query.filters
Class Filters
java.lang.Object
dev.morphia.query.filters.Filters
Defines helper methods to generate filter operations for queries.
- Since:
- 2.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic FilterMatches arrays that contain all elements specified in the query.static FilterApplies $and to a set of filtersstatic FilterbitsAllClear(String field, Object val) Matches numeric or binary values in which a set of bit positions all have a value of 0.static FilterbitsAllSet(String field, Object val) Matches numeric or binary values in which a set of bit positions all have a value of 1.static FilterbitsAnyClear(String field, Object val) Matches numeric or binary values in which any bit from a set of bit positions has a value of 0.static FilterbitsAnySet(String field, Object val) Matches numeric or binary values in which any bit from a set of bit positions has a value of 1.static FilterSpecifies a rectangular box using legacy coordinate pairs for $geoWithin queries.static FilterSpecifies a circle using legacy coordinate pairs to $geoWithin queries when using planar geometry.static FiltercenterSphere(String field, Point center, double radius) Defines a circle for a geospatial query that uses spherical geometry.static FilterAdds a comment to a query predicate.static FilterSelects documents if a value in the results matches all the specified $elemMatch conditions.static FilterSelects documents if element in the array field matches all the specified $elemMatch conditions.static FilterSpecifies equality condition.static FilterMatches documents that have the specified field.static Filterexpr(Expression expression) Allows use of aggregation expressions within the query language.static FiltergeoIntersects(String field, Geometry val) Selects geometries that intersect with a GeoJSON geometry.static FilterSpecifies a geometry in GeoJSON format to geospatial query operators.static GeoWithinFiltergeoWithin(String field, MultiPolygon polygon) Selects geometries within a bounding GeoJSON geometry.static GeoWithinFilterSelects geometries within a bounding GeoJSON geometry.static Filter$gt selects those documents where the value is greater than the specified value.static Filter$gt selects those documents where the value of the field is greater than the specified value.static Filter$gte selects the documents where the value of the target field is greater than or equal to a specified valuestatic Filter$gte selects the documents where the value of the field is greater than or equal to a specified valuestatic FilterThe $in operator selects the documents where the value of a field equals any value in a given array.static FilterThe $in operator selects the documents where the value of a field equals any value in the specified array.static FilterjsonSchema(Document schema) Filters documents against the given JSON Schema.static Filter$lt selects the documents where the value of the field is less than the specified value.static Filter$lt selects the documents where the value of the field is less than the specified value.static Filter$lte selects the documents where the value is less than or equal to the specified value.static Filter$lte selects the documents where the value of the field is less than or equal to the specified value.static FiltermaxDistance(String field, Object val) Specifies a maximum distance to limit the results of $near and $nearSphere queries.static FilterminDistance(String field, Object val) Specifies a minimum distance to limit the results of $near and $nearSphere queries.static FilterPerforms a modulo operation on the value of a field and selects documents with a specified result.static FilterPerforms a modulo operation on the value of a field and selects documents with a specified result.static Filter$ne selects the documents where the value of the field is not equal to the specified value.static NearFilterSpecifies a point for which a geospatial query returns the documents from nearest to farthest.static NearFilternearSphere(String field, Point point) Returns geospatial objects in proximity to a point on a sphere.static Filter$nin selects the documents where: the field value is not in the specified array or the field does not exist.static FilterApplies $nor to a set of filtersstatic FilterApplies $or to a set of filtersstatic FilterSpecifies a polygon to using legacy coordinate pairs for $geoWithin queries.static RegexFilterSelects documents where values match a specified regular expression.static RegexFilterSelects documents where values match a specified regular expression.static FilterSelects documents if the array field is a specified size.static TextSearchFilterPerforms text search.static FilterSelects documents if a field is of the specified type.static FilteruniqueDocs(String field, Object val) Deprecated.static FilterMatches documents that satisfy a JavaScript expression.
-
Method Details
-
all
Matches arrays that contain all elements specified in the query.- Parameters:
field- the field to checkval- the value to check- Returns:
- the filter
- MongoDB documentation
- Query Filter: $all
-
and
Applies $and to a set of filters- Parameters:
filters- the filters- Returns:
- the filter
- MongoDB documentation
- Query Filter: $and
-
bitsAllClear
Matches numeric or binary values in which a set of bit positions all have a value of 0.- Parameters:
field- the field to checkval- the value to check- Returns:
- the filter
- Since:
- 3.0 changed to take a plain Object instead of overloading
- MongoDB documentation
- Query Filter: $bitsAllClear
-
bitsAllSet
Matches numeric or binary values in which a set of bit positions all have a value of 1.- Parameters:
field- the field to checkval- the value to check- Returns:
- the filter
- Since:
- 3.0 changed to take a plain Object instead of overloading
- MongoDB documentation
- Query Filter: $bitsAllSet
-
bitsAnyClear
Matches numeric or binary values in which any bit from a set of bit positions has a value of 0.- Parameters:
field- the field to checkval- the value to check- Returns:
- the filter
- MongoDB documentation
- Query Filter: $bitsAnyClear
-
bitsAnySet
Matches numeric or binary values in which any bit from a set of bit positions has a value of 1.- Parameters:
field- the field to checkval- the value to check- Returns:
- the filter
- MongoDB documentation
- Query Filter: $bitsAnySet
-
box
Specifies a rectangular box using legacy coordinate pairs for $geoWithin queries. The 2d index supports $box.- Parameters:
field- the field to checkbottomLeft- the bottom left corner of the boxupperRight- the upper right corner of the box- Returns:
- the filter
- MongoDB documentation
- Query Filter: $box
-
center
Specifies a circle using legacy coordinate pairs to $geoWithin queries when using planar geometry. The 2d index supports $center.- Parameters:
field- the field to checkcenter- the center point of the shaperadius- the radius of the circle- Returns:
- the filter
- MongoDB documentation
- Query Filter: $center
-
centerSphere
Defines a circle for a geospatial query that uses spherical geometry. The query returns documents that are within the bounds of the circle. You can use the $centerSphere operator on both GeoJSON objects and legacy coordinate pairs.To use $centerSphere, specify an array that contains:
- The grid coordinates of the circle’s center point, and
- The circle’s radius measured in radians. To calculate radians, see Calculate Distance Using Spherical Geometry.
- Parameters:
field- the field to checkcenter- the center point of the shaperadius- the radius of the circle- Returns:
- the filter
- MongoDB documentation
- Query Filter: $centerSphere
-
comment
Adds a comment to a query predicate.- Parameters:
comment- the comment to attach- Returns:
- the filter
- MongoDB documentation
- Query Filter: $comment
-
elemMatch
Selects documents if a value in the results matches all the specified $elemMatch conditions.- Parameters:
filters- the filters to evaluate against- Returns:
- the filter
- MongoDB documentation
- Query Filter: $elemMatch
-
elemMatch
Selects documents if element in the array field matches all the specified $elemMatch conditions.- Parameters:
field- the field to checkfilters- the filters to evaluate against- Returns:
- the filter
- MongoDB documentation
- Query Filter: $elemMatch
-
eq
Specifies equality condition. The $eq operator matches documents where the value of a field equals the specified value.- Parameters:
field- the field to checkval- the value to check- Returns:
- the filter
- MongoDB documentation
- Query Filter: $eq
-
exists
Matches documents that have the specified field.- Parameters:
field- the field to check- Returns:
- the filter
- MongoDB documentation
- Query Filter: $exists
-
expr
Allows use of aggregation expressions within the query language.- Parameters:
expression- the expression to evaluate- Returns:
- the filter
- MongoDB documentation
- Query Filter: $expr
-
geoIntersects
Selects geometries that intersect with a GeoJSON geometry. The 2dsphere index supports $geoIntersects.- Parameters:
field- the field to checkval- the value to check- Returns:
- the filter
- MongoDB documentation
- Query Filter: $geoIntersects
-
geoWithin
Selects geometries within a bounding GeoJSON geometry. The 2dsphere and 2d indexes support $geoWithin.- Parameters:
field- the field to checkpolygon- the polygon to check- Returns:
- the filter
- MongoDB documentation
- Query Filter: $geoWithin
-
geoWithin
Selects geometries within a bounding GeoJSON geometry. The 2dsphere and 2d indexes support $geoWithin.- Parameters:
field- the field to checkpolygon- the polygon to check- Returns:
- the filter
- MongoDB documentation
- Query Filter: $geoWithin
-
geometry
Specifies a geometry in GeoJSON format to geospatial query operators.- Parameters:
field- the field to checkval- the value to check- Returns:
- the filter
- MongoDB documentation
- Query Filter: $geometry
-
gt
$gt selects those documents where the value is greater than the specified value.- Parameters:
val- the value to check- Returns:
- the filter
- MongoDB documentation
- Query Filter: $gt
-
gt
$gt selects those documents where the value of the field is greater than the specified value.- Parameters:
field- the field to checkval- the value to check- Returns:
- the filter
- MongoDB documentation
- Query Filter: $gt
-
gte
$gte selects the documents where the value of the field is greater than or equal to a specified value- Parameters:
field- the field to checkval- the value to check- Returns:
- the filter
- MongoDB documentation
- Query Filter: $gte
-
gte
$gte selects the documents where the value of the target field is greater than or equal to a specified value- Parameters:
val- the value to check- Returns:
- the filter
- Since:
- 3.0
- MongoDB documentation
- Query Filter: $gte
-
in
The $in operator selects the documents where the value of a field equals any value in the specified array.- Parameters:
field- the field to checkval- the value to check- Returns:
- the filter
- MongoDB documentation
- Query Filter: $in
-
in
The $in operator selects the documents where the value of a field equals any value in a given array.- Parameters:
val- the values to check- Returns:
- the filter
- Since:
- 3.0
- MongoDB documentation
- Query Filter: $in
-
jsonSchema
Filters documents against the given JSON Schema.- Parameters:
schema- the schema to use- Returns:
- the filter
- Since:
- 2.1
- MongoDB documentation
- Query Filter: $jsonSchema
-
lt
$lt selects the documents where the value of the field is less than the specified value.- Parameters:
val- the value to check- Returns:
- the filter
- Since:
- 3.0
- MongoDB documentation
- Query Filter: $lt
-
lt
$lt selects the documents where the value of the field is less than the specified value.- Parameters:
field- the field to checkval- the value to check- Returns:
- the filter
- MongoDB documentation
- Query Filter: $lt
-
lte
$lte selects the documents where the value is less than or equal to the specified value.- Parameters:
val- the value to check- Returns:
- the filter
- MongoDB documentation
- Query Filter: $lte
-
lte
$lte selects the documents where the value of the field is less than or equal to the specified value.- Parameters:
field- the field to checkval- the value to check- Returns:
- the filter
- MongoDB documentation
- Query Filter: $lte
-
maxDistance
Specifies a maximum distance to limit the results of $near and $nearSphere queries. The 2dsphere and 2d indexes support $maxDistance.- Parameters:
field- the field to checkval- the value to check- Returns:
- the filter
- MongoDB documentation
- Query Filter: $maxDistance
-
minDistance
Specifies a minimum distance to limit the results of $near and $nearSphere queries. For use with 2dsphere index only.- Parameters:
field- the field to checkval- the value to check- Returns:
- the filter
- MongoDB documentation
- Query Filter: $minDistance
-
mod
Performs a modulo operation on the value of a field and selects documents with a specified result.- Parameters:
field- the field to checkdivisor- the value to divide byremainder- the remainder to check for- Returns:
- the filter
- MongoDB documentation
- Query Filter: $mod
-
mod
Performs a modulo operation on the value of a field and selects documents with a specified result.- Parameters:
field- the field to checkdivisor- the value to divide byremainder- the remainder to check for- Returns:
- the filter
- Since:
- 3.0
- MongoDB documentation
- Query Filter: $mod
-
ne
$ne selects the documents where the value of the field is not equal to the specified value. This includes documents that do not contain the field.- Parameters:
field- the field to checkval- the value to check- Returns:
- the filter
- MongoDB documentation
- Query Filter: $ne
-
near
Specifies a point for which a geospatial query returns the documents from nearest to farthest. The $near operator can specify either a GeoJSON point or legacy coordinate point.This requires a geospatial index.
- Parameters:
field- the field to checkpoint- the point to check- Returns:
- the filter
- MongoDB documentation
- Query Filter: $near
-
nearSphere
Returns geospatial objects in proximity to a point on a sphere.Requires a geospatial index. The 2dsphere and 2d indexes support $nearSphere.
- Parameters:
field- the field to checkpoint- the point to check- Returns:
- the filter
- MongoDB documentation
- Query Filter: $nearSphere
-
nin
$nin selects the documents where:- the field value is not in the specified array or
- the field does not exist.
- Parameters:
field- the field to checkval- the value to check- Returns:
- the filter
- MongoDB documentation
- Query Filter: $nin
-
nor
Applies $nor to a set of filters- Parameters:
filters- the filters- Returns:
- the filter
- MongoDB documentation
- Query Filter: $nor
-
or
Applies $or to a set of filters- Parameters:
filters- the filters- Returns:
- the filter
- MongoDB documentation
- Query Filter: $or
-
polygon
Specifies a polygon to using legacy coordinate pairs for $geoWithin queries. The 2d index supports $center.- Parameters:
field- the field to checkpoints- the value to check- Returns:
- the filter
- MongoDB documentation
- Query Filter: $polygon
-
regex
Selects documents where values match a specified regular expression.- Parameters:
field- the field to checkpattern- the regex pattern- Returns:
- the filter
- Since:
- 2.4.0
- MongoDB documentation
- Query Filter: $regex
- Since server release
- 1.9.0
-
regex
Selects documents where values match a specified regular expression.- Parameters:
field- the field to checkpattern- the regex pattern- Returns:
- the filter
- Since:
- 2.4.0
- MongoDB documentation
- Query Filter: $regex
- Since server release
- 1.9.0
-
size
Selects documents if the array field is a specified size.- Parameters:
field- the field to checksize- the size to check against- Returns:
- the filter
- MongoDB documentation
- Query Filter: $size
-
text
Performs text search.- Parameters:
textSearch- the text to search for- Returns:
- the filter
- MongoDB documentation
- Query Filter: $text
-
type
Selects documents if a field is of the specified type.- Parameters:
field- the field to checkval- the value to check- Returns:
- the filter
- MongoDB documentation
- Query Filter: $type
-
uniqueDocs
Deprecated. Modifies a $geoWithin and $near queries to ensure that even if a document matches the query multiple times, the query returns the document once.}- Parameters:
field- the field to checkval- the value to check- Returns:
- the filter
- MongoDB documentation
- Query Filter: $uniqueDocs
-
where
Matches documents that satisfy a JavaScript expression.- Parameters:
val- the value to check- Returns:
- the filter
- MongoDB documentation
- Query Filter: $where
-