public final class Filters
extends java.lang.Object
collection.find(and(eq("x", 1), lt("y", 3)));
Modifier and Type | Method and Description |
---|---|
static <TItem> Bson |
all(java.lang.String fieldName,
java.lang.Iterable<TItem> values)
Creates a filter that matches all documents where the value of a field is an array that contains all the specified values.
|
static <TItem> Bson |
all(java.lang.String fieldName,
TItem... values)
Creates a filter that matches all documents where the value of a field is an array that contains all the specified values.
|
static Bson |
and(Bson... filters)
Creates a filter that performs a logical AND of the provided list of filters.
|
static Bson |
and(java.lang.Iterable<Bson> filters)
Creates a filter that performs a logical AND of the provided list of filters.
|
static Bson |
bitsAllClear(java.lang.String fieldName,
long bitmask)
Creates a filter that matches all documents where all of the bit positions are clear in the field.
|
static Bson |
bitsAllSet(java.lang.String fieldName,
long bitmask)
Creates a filter that matches all documents where all of the bit positions are set in the field.
|
static Bson |
bitsAnyClear(java.lang.String fieldName,
long bitmask)
Creates a filter that matches all documents where any of the bit positions are clear in the field.
|
static Bson |
bitsAnySet(java.lang.String fieldName,
long bitmask)
Creates a filter that matches all documents where any of the bit positions are set in the field.
|
static Bson |
elemMatch(java.lang.String fieldName,
Bson filter)
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> Bson |
eq(java.lang.String fieldName,
TItem value)
Creates a filter that matches all documents where the value of the field name equals the specified value.
|
static <TItem> Bson |
eq(TItem value)
Creates a filter that matches all documents where the value of _id field equals the specified value.
|
static Bson |
exists(java.lang.String fieldName)
Creates a filter that matches all documents that contain the given field.
|
static Bson |
exists(java.lang.String fieldName,
boolean exists)
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> |
expr(TExpression expression)
Allows the use of aggregation expressions within the query language.
|
static Bson |
geoIntersects(java.lang.String fieldName,
Bson geometry)
Creates a filter that matches all documents containing a field with geospatial data that intersects with the specified shape.
|
static Bson |
geoIntersects(java.lang.String fieldName,
Geometry geometry)
Creates a filter that matches all documents containing a field with geospatial data that intersects with the specified shape.
|
static Bson |
geoWithin(java.lang.String fieldName,
Bson geometry)
Creates a filter that matches all documents containing a field with geospatial data that exists entirely within the specified shape.
|
static Bson |
geoWithin(java.lang.String fieldName,
Geometry geometry)
Creates a filter that matches all documents containing a field with geospatial data that exists entirely within the specified shape.
|
static Bson |
geoWithinBox(java.lang.String fieldName,
double lowerLeftX,
double lowerLeftY,
double upperRightX,
double upperRightY)
Creates a filter that matches all documents containing a field with grid coordinates data that exist entirely within the specified
box.
|
static Bson |
geoWithinCenter(java.lang.String fieldName,
double x,
double y,
double radius)
Creates a filter that matches all documents containing a field with grid coordinates data that exist entirely within the specified
circle.
|
static Bson |
geoWithinCenterSphere(java.lang.String fieldName,
double x,
double y,
double radius)
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 Bson |
geoWithinPolygon(java.lang.String fieldName,
java.util.List<java.util.List<java.lang.Double>> points)
Creates a filter that matches all documents containing a field with grid coordinates data that exist entirely within the specified
polygon.
|
static <TItem> Bson |
gt(java.lang.String fieldName,
TItem value)
Creates a filter that matches all documents where the value of the given field is greater than the specified value.
|
static <TItem> Bson |
gte(java.lang.String fieldName,
TItem value)
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> Bson |
in(java.lang.String fieldName,
java.lang.Iterable<TItem> values)
Creates a filter that matches all documents where the value of a field equals any value in the list of specified values.
|
static <TItem> Bson |
in(java.lang.String fieldName,
TItem... values)
Creates a filter that matches all documents where the value of a field equals any value in the list of specified values.
|
static Bson |
jsonSchema(Bson schema)
Creates a filter that matches all documents that validate against the given JSON schema document.
|
static <TItem> Bson |
lt(java.lang.String fieldName,
TItem value)
Creates a filter that matches all documents where the value of the given field is less than the specified value.
|
static <TItem> Bson |
lte(java.lang.String fieldName,
TItem value)
Creates a filter that matches all documents where the value of the given field is less than or equal to the specified value.
|
static Bson |
mod(java.lang.String fieldName,
long divisor,
long remainder)
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> Bson |
ne(java.lang.String fieldName,
TItem value)
Creates a filter that matches all documents where the value of the field name does not equal the specified value.
|
static Bson |
near(java.lang.String fieldName,
Bson geometry,
java.lang.Double maxDistance,
java.lang.Double minDistance)
Creates a filter that matches all documents containing a field with geospatial data that is near the specified GeoJSON point.
|
static Bson |
near(java.lang.String fieldName,
double x,
double y,
java.lang.Double maxDistance,
java.lang.Double minDistance)
Creates a filter that matches all documents containing a field with geospatial data that is near the specified point.
|
static Bson |
near(java.lang.String fieldName,
Point geometry,
java.lang.Double maxDistance,
java.lang.Double minDistance)
Creates a filter that matches all documents containing a field with geospatial data that is near the specified GeoJSON point.
|
static Bson |
nearSphere(java.lang.String fieldName,
Bson geometry,
java.lang.Double maxDistance,
java.lang.Double minDistance)
Creates a filter that matches all documents containing a field with geospatial data that is near the specified GeoJSON point using
spherical geometry.
|
static Bson |
nearSphere(java.lang.String fieldName,
double x,
double y,
java.lang.Double maxDistance,
java.lang.Double minDistance)
Creates a filter that matches all documents containing a field with geospatial data that is near the specified point using
spherical geometry.
|
static Bson |
nearSphere(java.lang.String fieldName,
Point geometry,
java.lang.Double maxDistance,
java.lang.Double minDistance)
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> Bson |
nin(java.lang.String fieldName,
java.lang.Iterable<TItem> values)
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> Bson |
nin(java.lang.String fieldName,
TItem... values)
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 Bson |
nor(Bson... filters)
Creates a filter that performs a logical NOR operation on all the specified filters.
|
static Bson |
nor(java.lang.Iterable<Bson> filters)
Creates a filter that performs a logical NOR operation on all the specified filters.
|
static Bson |
not(Bson filter)
Creates a filter that matches all documents that do not match the passed in filter.
|
static Bson |
or(Bson... filters)
Creates a filter that preforms a logical OR of the provided list of filters.
|
static Bson |
or(java.lang.Iterable<Bson> filters)
Creates a filter that preforms a logical OR of the provided list of filters.
|
static Bson |
regex(java.lang.String fieldName,
java.util.regex.Pattern pattern)
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 Bson |
regex(java.lang.String fieldName,
java.lang.String pattern)
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 Bson |
regex(java.lang.String fieldName,
java.lang.String pattern,
java.lang.String options)
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 Bson |
size(java.lang.String fieldName,
int size)
Creates a filter that matches all documents where the value of a field is an array of the specified size.
|
static Bson |
text(java.lang.String search)
Creates a filter that matches all documents matching the given search term.
|
static Bson |
text(java.lang.String search,
java.lang.String language)
Deprecated.
|
static Bson |
text(java.lang.String search,
TextSearchOptions textSearchOptions)
Creates a filter that matches all documents matching the given the search term with the given text search options.
|
static Bson |
type(java.lang.String fieldName,
BsonType type)
Creates a filter that matches all documents where the value of the field is of the specified BSON type.
|
static Bson |
type(java.lang.String fieldName,
java.lang.String type)
Creates a filter that matches all documents where the value of the field is of the specified BSON type.
|
static Bson |
where(java.lang.String javaScriptExpression)
Creates a filter that matches all documents for which the given expression is true.
|
public static <TItem> Bson eq(@Nullable TItem value)
TItem
- the value typevalue
- the value, which may be nullpublic static <TItem> Bson eq(java.lang.String fieldName, @Nullable TItem value)
TItem
- the value typefieldName
- the field namevalue
- the value, which may be nullpublic static <TItem> Bson ne(java.lang.String fieldName, @Nullable TItem value)
TItem
- the value typefieldName
- the field namevalue
- the value, which may be nullpublic static <TItem> Bson gt(java.lang.String fieldName, TItem value)
TItem
- the value typefieldName
- the field namevalue
- the valuepublic static <TItem> Bson lt(java.lang.String fieldName, TItem value)
TItem
- the value typefieldName
- the field namevalue
- the valuepublic static <TItem> Bson gte(java.lang.String fieldName, TItem value)
TItem
- the value typefieldName
- the field namevalue
- the valuepublic static <TItem> Bson lte(java.lang.String fieldName, TItem value)
TItem
- the value typefieldName
- the field namevalue
- the valuepublic static <TItem> Bson in(java.lang.String fieldName, TItem... values)
TItem
- the value typefieldName
- the field namevalues
- the list of valuespublic static <TItem> Bson in(java.lang.String fieldName, java.lang.Iterable<TItem> values)
TItem
- the value typefieldName
- the field namevalues
- the list of valuespublic static <TItem> Bson nin(java.lang.String fieldName, TItem... values)
TItem
- the value typefieldName
- the field namevalues
- the list of valuespublic static <TItem> Bson nin(java.lang.String fieldName, java.lang.Iterable<TItem> values)
TItem
- the value typefieldName
- the field namevalues
- the list of valuespublic static Bson and(java.lang.Iterable<Bson> filters)
will generate a MongoDB query like:and(eq("x", 1), lt("y", 3))
{x : 1, y : {$lt : 3}}
filters
- the list of filters to and togetherpublic static Bson and(Bson... filters)
will generate a MongoDB query like:and(eq("x", 1), lt("y", 3))
{x : 1, y : {$lt : 3}}
filters
- the list of filters to and togetherpublic static Bson or(java.lang.Iterable<Bson> filters)
filters
- the list of filters to and togetherpublic static Bson or(Bson... filters)
filters
- the list of filters to and togetherpublic static Bson not(Bson filter)
will generate a MongoDB query like:not(eq("x", 1))
{x : $not: {$eq : 1}}
filter
- the valuepublic static Bson nor(Bson... filters)
filters
- the list of valuespublic static Bson nor(java.lang.Iterable<Bson> filters)
filters
- the list of valuespublic static Bson exists(java.lang.String fieldName)
fieldName
- the field namepublic static Bson exists(java.lang.String fieldName, boolean exists)
fieldName
- the field nameexists
- true to check for existence, false to check for absencepublic static Bson type(java.lang.String fieldName, BsonType type)
fieldName
- the field nametype
- the BSON typepublic static Bson type(java.lang.String fieldName, java.lang.String type)
fieldName
- the field nametype
- the string representation of the BSON typepublic static Bson mod(java.lang.String fieldName, long divisor, long remainder)
fieldName
- the field namedivisor
- the modulusremainder
- the remainderpublic static Bson regex(java.lang.String fieldName, java.lang.String pattern)
fieldName
- the field namepattern
- the patternpublic static Bson regex(java.lang.String fieldName, java.lang.String pattern, @Nullable java.lang.String options)
fieldName
- the field namepattern
- the patternoptions
- the optionspublic static Bson regex(java.lang.String fieldName, java.util.regex.Pattern pattern)
fieldName
- the field namepattern
- the patternpublic static Bson text(java.lang.String search)
search
- the search term@Deprecated public static Bson text(java.lang.String search, java.lang.String language)
text(String, TextSearchOptions)
search
- the search termlanguage
- the language to use for stop wordspublic static Bson text(java.lang.String search, TextSearchOptions textSearchOptions)
search
- the search termtextSearchOptions
- the text search options to usepublic static Bson where(java.lang.String javaScriptExpression)
javaScriptExpression
- the JavaScript expressionpublic static <TExpression> Bson expr(TExpression expression)
TExpression
- the expression typeexpression
- the aggregation expressionpublic static <TItem> Bson all(java.lang.String fieldName, TItem... values)
TItem
- the value typefieldName
- the field namevalues
- the list of valuespublic static <TItem> Bson all(java.lang.String fieldName, java.lang.Iterable<TItem> values)
TItem
- the value typefieldName
- the field namevalues
- the list of valuespublic static Bson elemMatch(java.lang.String fieldName, Bson filter)
fieldName
- the field namefilter
- the filter to apply to each elementpublic static Bson size(java.lang.String fieldName, int size)
fieldName
- the field namesize
- the size of the arraypublic static Bson bitsAllClear(java.lang.String fieldName, long bitmask)
fieldName
- the field namebitmask
- the bitmaskpublic static Bson bitsAllSet(java.lang.String fieldName, long bitmask)
fieldName
- the field namebitmask
- the bitmaskpublic static Bson bitsAnyClear(java.lang.String fieldName, long bitmask)
fieldName
- the field namebitmask
- the bitmaskpublic static Bson bitsAnySet(java.lang.String fieldName, long bitmask)
fieldName
- the field namebitmask
- the bitmaskpublic static Bson geoWithin(java.lang.String fieldName, Geometry geometry)
fieldName
- the field namegeometry
- the bounding GeoJSON geometry objectpublic static Bson geoWithin(java.lang.String fieldName, Bson geometry)
fieldName
- the field namegeometry
- the bounding GeoJSON geometry objectpublic static Bson geoWithinBox(java.lang.String fieldName, double lowerLeftX, double lowerLeftY, double upperRightX, double upperRightY)
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 boxpublic static Bson geoWithinPolygon(java.lang.String fieldName, java.util.List<java.util.List<java.lang.Double>> points)
fieldName
- the field namepoints
- a list of pairs of x, y coordinates. Any extra dimensions are ignoredpublic static Bson geoWithinCenter(java.lang.String fieldName, double x, double y, double radius)
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 systempublic static Bson geoWithinCenterSphere(java.lang.String fieldName, double x, double y, double radius)
fieldName
- the field namex
- the x coordinate of the circley
- the y coordinate of the circleradius
- the radius of the circle, in radianspublic static Bson geoIntersects(java.lang.String fieldName, Bson geometry)
fieldName
- the field namegeometry
- the bounding GeoJSON geometry objectpublic static Bson geoIntersects(java.lang.String fieldName, Geometry geometry)
fieldName
- the field namegeometry
- the bounding GeoJSON geometry objectpublic static Bson near(java.lang.String fieldName, Point geometry, @Nullable java.lang.Double maxDistance, @Nullable java.lang.Double minDistance)
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.public static Bson near(java.lang.String fieldName, Bson geometry, @Nullable java.lang.Double maxDistance, @Nullable java.lang.Double minDistance)
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.public static Bson near(java.lang.String fieldName, double x, double y, @Nullable java.lang.Double maxDistance, @Nullable java.lang.Double minDistance)
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.public static Bson nearSphere(java.lang.String fieldName, Point geometry, @Nullable java.lang.Double maxDistance, @Nullable java.lang.Double minDistance)
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.public static Bson nearSphere(java.lang.String fieldName, Bson geometry, @Nullable java.lang.Double maxDistance, @Nullable java.lang.Double minDistance)
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.public static Bson nearSphere(java.lang.String fieldName, double x, double y, @Nullable java.lang.Double maxDistance, @Nullable java.lang.Double minDistance)
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.Copyright © 2010 - 2023 Adobe. All Rights Reserved