Package com.mongodb.client.model
Class Filters
java.lang.Object
com.mongodb.client.model.Filters
Deprecated.
Usage of this API is not supported in AEM as a Cloud Service.
A factory for query filters. A convenient way to use this class is to statically import all of its methods, which allows usage like:
collection.find(and(eq("x", 1), lt("y", 3)));
- Since:
- 3.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic <TItem> BsonDeprecated.Creates a filter that matches all documents where the value of a field is an array that contains all the specified values.static <TItem> BsonDeprecated.Creates a filter that matches all documents where the value of a field is an array that contains all the specified values.static BsonDeprecated.Creates a filter that performs a logical AND of the provided list of filters.static BsonDeprecated.Creates a filter that performs a logical AND of the provided list of filters.static BsonbitsAllClear(String fieldName, long bitmask) Deprecated.Creates a filter that matches all documents where all of the bit positions are clear in the field.static BsonbitsAllSet(String fieldName, long bitmask) Deprecated.Creates a filter that matches all documents where all of the bit positions are set in the field.static BsonbitsAnyClear(String fieldName, long bitmask) Deprecated.Creates a filter that matches all documents where any of the bit positions are clear in the field.static BsonbitsAnySet(String fieldName, long bitmask) Deprecated.Creates a filter that matches all documents where any of the bit positions are set in the field.static BsonDeprecated.Creates a filter that matches all documents containing a field that is an array where at least one member of the array matches the given filter.static <TItem> BsonDeprecated.Creates a filter that matches all documents where the value of the field name equals the specified value.static <TItem> Bsoneq(TItem value) Deprecated.Creates a filter that matches all documents where the value of _id field equals the specified value.static BsonDeprecated.Creates a filter that matches all documents that contain the given field.static BsonDeprecated.Creates a filter that matches all documents that either contain or do not contain the given field, depending on the value of the exists parameter.static <TExpression>
Bsonexpr(TExpression expression) Deprecated.Allows the use of aggregation expressions within the query language.static BsongeoIntersects(String fieldName, Geometry geometry) Deprecated.Creates a filter that matches all documents containing a field with geospatial data that intersects with the specified shape.static BsongeoIntersects(String fieldName, Bson geometry) Deprecated.Creates a filter that matches all documents containing a field with geospatial data that intersects with the specified shape.static BsonDeprecated.Creates a filter that matches all documents containing a field with geospatial data that exists entirely within the specified shape.static BsonDeprecated.Creates a filter that matches all documents containing a field with geospatial data that exists entirely within the specified shape.static BsongeoWithinBox(String fieldName, double lowerLeftX, double lowerLeftY, double upperRightX, double upperRightY) Deprecated.Creates a filter that matches all documents containing a field with grid coordinates data that exist entirely within the specified box.static BsongeoWithinCenter(String fieldName, double x, double y, double radius) Deprecated.Creates a filter that matches all documents containing a field with grid coordinates data that exist entirely within the specified circle.static BsongeoWithinCenterSphere(String fieldName, double x, double y, double radius) Deprecated.Creates a filter that matches all documents containing a field with geospatial data (GeoJSON or legacy coordinate pairs) that exist entirely within the specified circle, using spherical geometry.static BsongeoWithinPolygon(String fieldName, List<List<Double>> points) Deprecated.Creates a filter that matches all documents containing a field with grid coordinates data that exist entirely within the specified polygon.static <TItem> BsonDeprecated.Creates a filter that matches all documents where the value of the given field is greater than the specified value.static <TItem> BsonDeprecated.Creates a filter that matches all documents where the value of the given field is greater than or equal to the specified value.static <TItem> BsonDeprecated.Creates a filter that matches all documents where the value of a field equals any value in the list of specified values.static <TItem> BsonDeprecated.Creates a filter that matches all documents where the value of a field equals any value in the list of specified values.static BsonjsonSchema(Bson schema) Deprecated.Creates a filter that matches all documents that validate against the given JSON schema document.static <TItem> BsonDeprecated.Creates a filter that matches all documents where the value of the given field is less than the specified value.static <TItem> BsonDeprecated.Creates a filter that matches all documents where the value of the given field is less than or equal to the specified value.static BsonDeprecated.Creates a filter that matches all documents where the value of a field divided by a divisor has the specified remainder (i.e.static <TItem> BsonDeprecated.Creates a filter that matches all documents where the value of the field name does not equal the specified value.static BsonDeprecated.Creates a filter that matches all documents containing a field with geospatial data that is near the specified point.static BsonDeprecated.Creates a filter that matches all documents containing a field with geospatial data that is near the specified GeoJSON point.static BsonDeprecated.Creates a filter that matches all documents containing a field with geospatial data that is near the specified GeoJSON point.static BsonnearSphere(String fieldName, double x, double y, Double maxDistance, Double minDistance) Deprecated.Creates a filter that matches all documents containing a field with geospatial data that is near the specified point using spherical geometry.static BsonnearSphere(String fieldName, Point geometry, Double maxDistance, Double minDistance) Deprecated.Creates a filter that matches all documents containing a field with geospatial data that is near the specified GeoJSON point using spherical geometry.static BsonnearSphere(String fieldName, Bson geometry, Double maxDistance, Double minDistance) Deprecated.Creates a filter that matches all documents containing a field with geospatial data that is near the specified GeoJSON point using spherical geometry.static <TItem> BsonDeprecated.Creates a filter that matches all documents where the value of a field does not equal any of the specified values or does not exist.static <TItem> BsonDeprecated.Creates a filter that matches all documents where the value of a field does not equal any of the specified values or does not exist.static BsonDeprecated.Creates a filter that performs a logical NOR operation on all the specified filters.static BsonDeprecated.Creates a filter that performs a logical NOR operation on all the specified filters.static BsonDeprecated.Creates a filter that matches all documents that do not match the passed in filter.static BsonDeprecated.Creates a filter that preforms a logical OR of the provided list of filters.static BsonDeprecated.Creates a filter that preforms a logical OR of the provided list of filters.static BsonDeprecated.Creates a filter that matches all documents where the value of the field matches the given regular expression pattern with the given options applied.static BsonDeprecated.Creates a filter that matches all documents where the value of the field matches the given regular expression pattern with the given options applied.static BsonDeprecated.Creates a filter that matches all documents where the value of the field matches the given regular expression pattern with the given options applied.static BsonDeprecated.Creates a filter that matches all documents where the value of a field is an array of the specified size.static BsonDeprecated.Creates a filter that matches all documents matching the given search term.static Bsontext(String search, TextSearchOptions textSearchOptions) Deprecated.Creates a filter that matches all documents matching the given the search term with the given text search options.static BsonDeprecated.static BsonDeprecated.Creates a filter that matches all documents where the value of the field is of the specified BSON type.static BsonDeprecated.Creates a filter that matches all documents where the value of the field is of the specified BSON type.static BsonDeprecated.Creates a filter that matches all documents for which the given expression is true.
-
Method Details
-
eq
Deprecated.Creates a filter that matches all documents where the value of _id field equals the specified value. Note that this doesn't actually generate a $eq operator, as the query language doesn't require it.- Type Parameters:
TItem- the value type- Parameters:
value- the value, which may be null- Returns:
- the filter
- Since:
- 3.4
-
eq
Deprecated.Creates a filter that matches all documents where the value of the field name equals the specified value. Note that this doesn't actually generate a $eq operator, as the query language doesn't require it.- Type Parameters:
TItem- the value type- Parameters:
fieldName- the field namevalue- the value, which may be null- Returns:
- the filter
-
ne
Deprecated.Creates a filter that matches all documents where the value of the field name does not equal the specified value.- Type Parameters:
TItem- the value type- Parameters:
fieldName- the field namevalue- the value, which may be null- Returns:
- the filter
-
gt
Deprecated.Creates a filter that matches all documents where the value of the given field is greater than the specified value.- Type Parameters:
TItem- the value type- Parameters:
fieldName- the field namevalue- the value- Returns:
- the filter
-
lt
Deprecated.Creates a filter that matches all documents where the value of the given field is less than the specified value.- Type Parameters:
TItem- the value type- Parameters:
fieldName- the field namevalue- the value- Returns:
- the filter
-
gte
Deprecated.Creates a filter that matches all documents where the value of the given field is greater than or equal to the specified value.- Type Parameters:
TItem- the value type- Parameters:
fieldName- the field namevalue- the value- Returns:
- the filter
-
lte
Deprecated.Creates a filter that matches all documents where the value of the given field is less than or equal to the specified value.- Type Parameters:
TItem- the value type- Parameters:
fieldName- the field namevalue- the value- Returns:
- the filter
-
in
Deprecated.Creates a filter that matches all documents where the value of a field equals any value in the list of specified values.- Type Parameters:
TItem- the value type- Parameters:
fieldName- the field namevalues- the list of values- Returns:
- the filter
-
in
Deprecated.Creates a filter that matches all documents where the value of a field equals any value in the list of specified values.- Type Parameters:
TItem- the value type- Parameters:
fieldName- the field namevalues- the list of values- Returns:
- the filter
-
nin
Deprecated.Creates a filter that matches all documents where the value of a field does not equal any of the specified values or does not exist.- Type Parameters:
TItem- the value type- Parameters:
fieldName- the field namevalues- the list of values- Returns:
- the filter
-
nin
Deprecated.Creates a filter that matches all documents where the value of a field does not equal any of the specified values or does not exist.- Type Parameters:
TItem- the value type- Parameters:
fieldName- the field namevalues- the list of values- Returns:
- the filter
-
and
Deprecated.Creates a filter that performs a logical AND of the provided list of filters. Note that this will only generate a "$and" operator if absolutely necessary, as the query language implicity ands together all the keys. In other words, a query expression like:
will generate a MongoDB query like:and(eq("x", 1), lt("y", 3)){x : 1, y : {$lt : 3}}- Parameters:
filters- the list of filters to and together- Returns:
- the filter
-
and
Deprecated.Creates a filter that performs a logical AND of the provided list of filters. Note that this will only generate a "$and" operator if absolutely necessary, as the query language implicity ands together all the keys. In other words, a query expression like:
will generate a MongoDB query like:and(eq("x", 1), lt("y", 3)){x : 1, y : {$lt : 3}}- Parameters:
filters- the list of filters to and together- Returns:
- the filter
-
or
Deprecated.Creates a filter that preforms a logical OR of the provided list of filters.- Parameters:
filters- the list of filters to and together- Returns:
- the filter
-
or
Deprecated.Creates a filter that preforms a logical OR of the provided list of filters.- Parameters:
filters- the list of filters to and together- Returns:
- the filter
-
not
Deprecated.Creates a filter that matches all documents that do not match the passed in filter. Requires the field name to passed as part of the value passed in and lifts it to create a valid "$not" query:
will generate a MongoDB query like:not(eq("x", 1)){x : $not: {$eq : 1}}- Parameters:
filter- the value- Returns:
- the filter
-
nor
Deprecated.Creates a filter that performs a logical NOR operation on all the specified filters.- Parameters:
filters- the list of values- Returns:
- the filter
-
nor
Deprecated.Creates a filter that performs a logical NOR operation on all the specified filters.- Parameters:
filters- the list of values- Returns:
- the filter
-
exists
Deprecated.Creates a filter that matches all documents that contain the given field.- Parameters:
fieldName- the field name- Returns:
- the filter
-
exists
Deprecated.Creates a filter that matches all documents that either contain or do not contain the given field, depending on the value of the exists parameter.- Parameters:
fieldName- the field nameexists- true to check for existence, false to check for absence- Returns:
- the filter
-
type
Deprecated.Creates a filter that matches all documents where the value of the field is of the specified BSON type.- Parameters:
fieldName- the field nametype- the BSON type- Returns:
- the filter
-
type
Deprecated.Creates a filter that matches all documents where the value of the field is of the specified BSON type.- Parameters:
fieldName- the field nametype- the string representation of the BSON type- Returns:
- the filter
-
mod
Deprecated.Creates a filter that matches all documents where the value of a field divided by a divisor has the specified remainder (i.e. perform a modulo operation to select documents).- Parameters:
fieldName- the field namedivisor- the modulusremainder- the remainder- Returns:
- the filter
-
regex
Deprecated.Creates a filter that matches all documents where the value of the field matches the given regular expression pattern with the given options applied.- Parameters:
fieldName- the field namepattern- the pattern- Returns:
- the filter
-
regex
Deprecated.Creates a filter that matches all documents where the value of the field matches the given regular expression pattern with the given options applied.- Parameters:
fieldName- the field namepattern- the patternoptions- the options- Returns:
- the filter
-
regex
Deprecated.Creates a filter that matches all documents where the value of the field matches the given regular expression pattern with the given options applied.- Parameters:
fieldName- the field namepattern- the pattern- Returns:
- the filter
-
text
Deprecated.Creates a filter that matches all documents matching the given search term.- Parameters:
search- the search term- Returns:
- the filter
-
text
Deprecated.Creates a filter that matches all documents matching the given search term using the given language.- Parameters:
search- the search termlanguage- the language to use for stop words- Returns:
- the filter
-
text
Deprecated.Creates a filter that matches all documents matching the given the search term with the given text search options.- Parameters:
search- the search termtextSearchOptions- the text search options to use- Returns:
- the filter
- Since:
- 3.2
-
where
Deprecated.Creates a filter that matches all documents for which the given expression is true.- Parameters:
javaScriptExpression- the JavaScript expression- Returns:
- the filter
-
expr
Deprecated.Allows the use of aggregation expressions within the query language.- Type Parameters:
TExpression- the expression type- Parameters:
expression- the aggregation expression- Returns:
- the filter
- Since:
- 3.6
-
all
Deprecated.Creates a filter that matches all documents where the value of a field is an array that contains all the specified values.- Type Parameters:
TItem- the value type- Parameters:
fieldName- the field namevalues- the list of values- Returns:
- the filter
-
all
Deprecated.Creates a filter that matches all documents where the value of a field is an array that contains all the specified values.- Type Parameters:
TItem- the value type- Parameters:
fieldName- the field namevalues- the list of values- Returns:
- the filter
-
elemMatch
Deprecated.Creates a filter that matches all documents containing a field that is an array where at least one member of the array matches the given filter.- Parameters:
fieldName- the field namefilter- the filter to apply to each element- Returns:
- the filter
-
size
Deprecated.Creates a filter that matches all documents where the value of a field is an array of the specified size.- Parameters:
fieldName- the field namesize- the size of the array- Returns:
- the filter
-
bitsAllClear
Deprecated.Creates a filter that matches all documents where all of the bit positions are clear in the field.- Parameters:
fieldName- the field namebitmask- the bitmask- Returns:
- the filter
- Since:
- 3.2
-
bitsAllSet
Deprecated.Creates a filter that matches all documents where all of the bit positions are set in the field.- Parameters:
fieldName- the field namebitmask- the bitmask- Returns:
- the filter
- Since:
- 3.2
-
bitsAnyClear
Deprecated.Creates a filter that matches all documents where any of the bit positions are clear in the field.- Parameters:
fieldName- the field namebitmask- the bitmask- Returns:
- the filter
- Since:
- 3.2
-
bitsAnySet
Deprecated.Creates a filter that matches all documents where any of the bit positions are set in the field.- Parameters:
fieldName- the field namebitmask- the bitmask- Returns:
- the filter
- Since:
- 3.2
-
geoWithin
Deprecated.Creates a filter that matches all documents containing a field with geospatial data that exists entirely within the specified shape.- Parameters:
fieldName- the field namegeometry- the bounding GeoJSON geometry object- Returns:
- the filter
- Since:
- 3.1
-
geoWithin
Deprecated.Creates a filter that matches all documents containing a field with geospatial data that exists entirely within the specified shape.- Parameters:
fieldName- the field namegeometry- the bounding GeoJSON geometry object- Returns:
- the filter
- Since:
- 3.1
-
geoWithinBox
public static Bson geoWithinBox(String fieldName, double lowerLeftX, double lowerLeftY, double upperRightX, double upperRightY) Deprecated.Creates a filter that matches all documents containing a field with grid coordinates data that exist entirely within the specified box.- Parameters:
fieldName- the field namelowerLeftX- the lower left x coordinate of the boxlowerLeftY- the lower left y coordinate of the boxupperRightX- the upper left x coordinate of the boxupperRightY- the upper left y coordinate of the box- Returns:
- the filter
- Since:
- 3.1
-
geoWithinPolygon
Deprecated.Creates a filter that matches all documents containing a field with grid coordinates data that exist entirely within the specified polygon.- Parameters:
fieldName- the field namepoints- a list of pairs of x, y coordinates. Any extra dimensions are ignored- Returns:
- the filter
- Since:
- 3.1
-
geoWithinCenter
Deprecated.Creates a filter that matches all documents containing a field with grid coordinates data that exist entirely within the specified circle.- Parameters:
fieldName- the field namex- the x coordinate of the circley- the y coordinate of the circleradius- the radius of the circle, as measured in the units used by the coordinate system- Returns:
- the filter
- Since:
- 3.1
-
geoWithinCenterSphere
Deprecated.Creates a filter that matches all documents containing a field with geospatial data (GeoJSON or legacy coordinate pairs) that exist entirely within the specified circle, using spherical geometry. If using longitude and latitude, specify longitude first.- Parameters:
fieldName- the field namex- the x coordinate of the circley- the y coordinate of the circleradius- the radius of the circle, in radians- Returns:
- the filter
- Since:
- 3.1
-
geoIntersects
Deprecated.Creates a filter that matches all documents containing a field with geospatial data that intersects with the specified shape.- Parameters:
fieldName- the field namegeometry- the bounding GeoJSON geometry object- Returns:
- the filter
- Since:
- 3.1
-
geoIntersects
Deprecated.Creates a filter that matches all documents containing a field with geospatial data that intersects with the specified shape.- Parameters:
fieldName- the field namegeometry- the bounding GeoJSON geometry object- Returns:
- the filter
- Since:
- 3.1
-
near
public static Bson near(String fieldName, Point geometry, @Nullable Double maxDistance, @Nullable Double minDistance) Deprecated.Creates a filter that matches all documents containing a field with geospatial data that is near the specified GeoJSON point.- Parameters:
fieldName- the field namegeometry- the bounding GeoJSON geometry objectmaxDistance- the maximum distance from the point, in meters. It may be null.minDistance- the minimum distance from the point, in meters. It may be null.- Returns:
- the filter
- Since:
- 3.1
-
near
public static Bson near(String fieldName, Bson geometry, @Nullable Double maxDistance, @Nullable Double minDistance) Deprecated.Creates a filter that matches all documents containing a field with geospatial data that is near the specified GeoJSON point.- Parameters:
fieldName- the field namegeometry- the bounding GeoJSON geometry objectmaxDistance- the maximum distance from the point, in meters. It may be null.minDistance- the minimum distance from the point, in meters. It may be null.- Returns:
- the filter
- Since:
- 3.1
-
near
public static Bson near(String fieldName, double x, double y, @Nullable Double maxDistance, @Nullable Double minDistance) Deprecated.Creates a filter that matches all documents containing a field with geospatial data that is near the specified point.- Parameters:
fieldName- the field namex- the x coordinatey- the y coordinatemaxDistance- the maximum distance from the point, in radians. It may be null.minDistance- the minimum distance from the point, in radians. It may be null.- Returns:
- the filter
- Since:
- 3.1
-
nearSphere
public static Bson nearSphere(String fieldName, Point geometry, @Nullable Double maxDistance, @Nullable Double minDistance) Deprecated.Creates a filter that matches all documents containing a field with geospatial data that is near the specified GeoJSON point using spherical geometry.- Parameters:
fieldName- the field namegeometry- the bounding GeoJSON geometry objectmaxDistance- the maximum distance from the point, in meters. It may be null.minDistance- the minimum distance from the point, in meters. It may be null.- Returns:
- the filter
- Since:
- 3.1
-
nearSphere
public static Bson nearSphere(String fieldName, Bson geometry, @Nullable Double maxDistance, @Nullable Double minDistance) Deprecated.Creates a filter that matches all documents containing a field with geospatial data that is near the specified GeoJSON point using spherical geometry.- Parameters:
fieldName- the field namegeometry- the bounding GeoJSON geometry objectmaxDistance- the maximum distance from the point, in meters. It may be null.minDistance- the minimum distance from the point, in meters. It may be null.- Returns:
- the filter
- Since:
- 3.1
-
nearSphere
public static Bson nearSphere(String fieldName, double x, double y, @Nullable Double maxDistance, @Nullable Double minDistance) Deprecated.Creates a filter that matches all documents containing a field with geospatial data that is near the specified point using spherical geometry.- Parameters:
fieldName- the field namex- the x coordinatey- the y coordinatemaxDistance- the maximum distance from the point, in radians. It may be null.minDistance- the minimum distance from the point, in radians. It may be null.- Returns:
- the filter
- Since:
- 3.1
-
jsonSchema
Deprecated.Creates a filter that matches all documents that validate against the given JSON schema document.- Parameters:
schema- the JSON schema to validate against- Returns:
- the filter
- Since:
- 3.6
-