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 Filter
Matches arrays that contain all elements specified in the query.static Filter
Applies $and to a set of filtersstatic Filter
bitsAllClear
(String field, int bitMask) Matches numeric or binary values in which a set of bit positions all have a value of 0.static Filter
bitsAllClear
(String field, int[] positions) Matches numeric or binary values in which a set of bit positions all have a value of 0.static Filter
bitsAllSet
(String field, int bitMask) Matches numeric or binary values in which a set of bit positions all have a value of 1.static Filter
bitsAllSet
(String field, int[] positions) Matches numeric or binary values in which a set of bit positions all have a value of 1.static Filter
bitsAnyClear
(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 Filter
bitsAnySet
(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 Filter
Specifies a rectangular box using legacy coordinate pairs for $geoWithin queries.static Filter
Specifies a circle using legacy coordinate pairs to $geoWithin queries when using planar geometry.static Filter
centerSphere
(String field, Point center, double radius) Defines a circle for a geospatial query that uses spherical geometry.static Filter
Adds a comment to a query predicate.static Filter
Selects documents if element in the array field matches all the specified $elemMatch conditions.static Filter
Specifies equality condition.static Filter
Matches documents that have the specified field.static Filter
expr
(Expression expression) Allows use of aggregation expressions within the query language.static Filter
geoIntersects
(String field, Geometry val) Selects geometries that intersect with a GeoJSON geometry.static Filter
Specifies a geometry in GeoJSON format to geospatial query operators.static GeoWithinFilter
geoWithin
(String field, MultiPolygon polygon) Selects geometries within a bounding GeoJSON geometry.static GeoWithinFilter
Selects geometries within a bounding GeoJSON geometry.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 field is greater than or equal to a specified value (e.g.static Filter
The $in operator selects the documents where the value of a field equals any value in the specified array.static Filter
jsonSchema
(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
$lte selects the documents where the value of the field is less than or equal to the specified value.static Filter
maxDistance
(String field, Object val) Specifies a maximum distance to limit the results of $near and $nearSphere queries.static Filter
minDistance
(String field, Object val) Specifies a minimum distance to limit the results of $near and $nearSphere queries.static Filter
Performs 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 NearFilter
Specifies a point for which a geospatial query returns the documents from nearest to farthest.static NearFilter
nearSphere
(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 Filter
Applies $nor to a set of filtersstatic Filter
Applies $or to a set of filtersstatic Filter
Specifies a polygon to using legacy coordinate pairs for $geoWithin queries.static RegexFilter
Selects documents where values match a specified regular expression.static RegexFilter
Selects documents where values match a specified regular expression.static Filter
Selects documents if the array field is a specified size.static TextSearchFilter
Performs text search.static Filter
Selects documents if a field is of the specified type.static Filter
uniqueDocs
(String field, Object val) Deprecated.static Filter
Matches 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 checkpositions
- the value to check- Returns:
- the filter
- MongoDB documentation
- Query Filter: $bitsAllClear
-
bitsAllClear
Matches numeric or binary values in which a set of bit positions all have a value of 0.- Parameters:
field
- the field to checkbitMask
- the numeric bitmask to use- Returns:
- the filter
- 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 checkbitMask
- the numeric bitmask to use- Returns:
- the filter
- MongoDB documentation
- Query Filter: $bitsAllSet
-
bitsAllSet
Matches numeric or binary values in which a set of bit positions all have a value of 1.- Parameters:
field
- the field to checkpositions
- the value to check- Returns:
- the filter
- 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:
field
- the field to checkval
- the value to check- Returns:
- the filter
- MongoDB documentation
- Query Filter: $comment
-
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 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 (e.g. value.)- Parameters:
field
- the field to checkval
- the value to check- Returns:
- the filter
- 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
-
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:
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 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
-
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
-
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
-
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
-