Filter

public classFilter


AFilter represents a restriction on one or more field values and can be used to refine the results of aQuery.

Summary

Public constructors

Public methods

static @NonNullFilter
and(Filter[] filters)

Creates a new filter that is a conjunction of the given filters.

static @NonNullFilter

Creates a new filter for checking that the given array field contains the given value.

static @NonNullFilter

Creates a new filter for checking that the given array field contains the given value.

static @NonNullFilter

Creates a new filter for checking that the given array field contains any of the given values.

static @NonNullFilter
arrayContainsAny(
    @NonNullFieldPath fieldPath,
    @NonNullList<Object> values
)

Creates a new filter for checking that the given array field contains any of the given values.

static @NonNullFilter

Creates a new filter for checking that the given field is equal to the given value.

static @NonNullFilter
equalTo(@NonNullFieldPath fieldPath, @NullableObject value)

Creates a new filter for checking that the given field is equal to the given value.

static @NonNullFilter

Creates a new filter for checking that the given field is greater than the given value.

static @NonNullFilter

Creates a new filter for checking that the given field is greater than the given value.

static @NonNullFilter

Creates a new filter for checking that the given field is greater than or equal to the given value.

static @NonNullFilter

Creates a new filter for checking that the given field is greater than or equal to the given value.

static @NonNullFilter

Creates a new filter for checking that the given field equals any of the given values.

static @NonNullFilter
inArray(@NonNullFieldPath fieldPath, @NonNullList<Object> values)

Creates a new filter for checking that the given field equals any of the given values.

static @NonNullFilter

Creates a new filter for checking that the given field is less than the given value.

static @NonNullFilter

Creates a new filter for checking that the given field is less than the given value.

static @NonNullFilter

Creates a new filter for checking that the given field is less than or equal to the given value.

static @NonNullFilter

Creates a new filter for checking that the given field is less than or equal to the given value.

static @NonNullFilter

Creates a new filter for checking that the given field is not equal to the given value.

static @NonNullFilter

Creates a new filter for checking that the given field is not equal to the given value.

static @NonNullFilter

Creates a new filter for checking that the given field does not equal any of the given values.

static @NonNullFilter

Creates a new filter for checking that the given field does not equal any of the given values.

static @NonNullFilter
or(Filter[] filters)

Creates a new filter that is a disjunction of the given filters.

Public constructors

Filter

public Filter()

Public methods

and

public static @NonNullFilter and(Filter[] filters)

Creates a new filter that is a conjunction of the given filters. A conjunction filter includes a document if it satisfiesall of the given filters.

Parameters
Filter[] filters

The list of filters to perform a conjunction for.

Returns
@NonNullFilter

The newly created filter.

arrayContains

public static @NonNullFilter arrayContains(@NonNullString field, @NullableObject value)

Creates a new filter for checking that the given array field contains the given value.

Parameters
@NonNullString field

The field used for the filter.

@NullableObject value

The value used for the filter.

Returns
@NonNullFilter

The newly created filter.

arrayContains

public static @NonNullFilter arrayContains(@NonNullFieldPath fieldPath, @NullableObject value)

Creates a new filter for checking that the given array field contains the given value.

Parameters
@NonNullFieldPath fieldPath

The field path used for the filter.

@NullableObject value

The value used for the filter.

Returns
@NonNullFilter

The newly created filter.

arrayContainsAny

public static @NonNullFilter arrayContainsAny(@NonNullString field, @NonNullList<Object> values)

Creates a new filter for checking that the given array field contains any of the given values.

Parameters
@NonNullString field

The field used for the filter.

@NonNullList<Object> values

The list of values used for the filter.

Returns
@NonNullFilter

The newly created filter.

arrayContainsAny

public static @NonNullFilter arrayContainsAny(
    @NonNullFieldPath fieldPath,
    @NonNullList<Object> values
)

Creates a new filter for checking that the given array field contains any of the given values.

Parameters
@NonNullFieldPath fieldPath

The field path used for the filter.

@NonNullList<Object> values

The list of values used for the filter.

Returns
@NonNullFilter

The newly created filter.

equalTo

public static @NonNullFilter equalTo(@NonNullString field, @NullableObject value)

Creates a new filter for checking that the given field is equal to the given value.

Parameters
@NonNullString field

The field used for the filter.

@NullableObject value

The value used for the filter.

Returns
@NonNullFilter

The newly created filter.

equalTo

public static @NonNullFilter equalTo(@NonNullFieldPath fieldPath, @NullableObject value)

Creates a new filter for checking that the given field is equal to the given value.

Parameters
@NonNullFieldPath fieldPath

The field path used for the filter.

@NullableObject value

The value used for the filter.

Returns
@NonNullFilter

The newly created filter.

greaterThan

public static @NonNullFilter greaterThan(@NonNullString field, @NullableObject value)

Creates a new filter for checking that the given field is greater than the given value.

Parameters
@NonNullString field

The field used for the filter.

@NullableObject value

The value used for the filter.

Returns
@NonNullFilter

The newly created filter.

greaterThan

public static @NonNullFilter greaterThan(@NonNullFieldPath fieldPath, @NullableObject value)

Creates a new filter for checking that the given field is greater than the given value.

Parameters
@NonNullFieldPath fieldPath

The field path used for the filter.

@NullableObject value

The value used for the filter.

Returns
@NonNullFilter

The newly created filter.

greaterThanOrEqualTo

public static @NonNullFilter greaterThanOrEqualTo(@NonNullString field, @NullableObject value)

Creates a new filter for checking that the given field is greater than or equal to the given value.

Parameters
@NonNullString field

The field used for the filter.

@NullableObject value

The value used for the filter.

Returns
@NonNullFilter

The newly created filter.

greaterThanOrEqualTo

public static @NonNullFilter greaterThanOrEqualTo(@NonNullFieldPath fieldPath, @NullableObject value)

Creates a new filter for checking that the given field is greater than or equal to the given value.

Parameters
@NonNullFieldPath fieldPath

The field path used for the filter.

@NullableObject value

The value used for the filter.

Returns
@NonNullFilter

The newly created filter.

inArray

public static @NonNullFilter inArray(@NonNullString field, @NonNullList<Object> values)

Creates a new filter for checking that the given field equals any of the given values.

Parameters
@NonNullString field

The field used for the filter.

@NonNullList<Object> values

The list of values used for the filter.

Returns
@NonNullFilter

The newly created filter.

inArray

public static @NonNullFilter inArray(@NonNullFieldPath fieldPath, @NonNullList<Object> values)

Creates a new filter for checking that the given field equals any of the given values.

Parameters
@NonNullFieldPath fieldPath

The field path used for the filter.

@NonNullList<Object> values

The list of values used for the filter.

Returns
@NonNullFilter

The newly created filter.

lessThan

public static @NonNullFilter lessThan(@NonNullString field, @NullableObject value)

Creates a new filter for checking that the given field is less than the given value.

Parameters
@NonNullString field

The field used for the filter.

@NullableObject value

The value used for the filter.

Returns
@NonNullFilter

The newly created filter.

lessThan

public static @NonNullFilter lessThan(@NonNullFieldPath fieldPath, @NullableObject value)

Creates a new filter for checking that the given field is less than the given value.

Parameters
@NonNullFieldPath fieldPath

The field path used for the filter.

@NullableObject value

The value used for the filter.

Returns
@NonNullFilter

The newly created filter.

lessThanOrEqualTo

public static @NonNullFilter lessThanOrEqualTo(@NonNullString field, @NullableObject value)

Creates a new filter for checking that the given field is less than or equal to the given value.

Parameters
@NonNullString field

The field used for the filter.

@NullableObject value

The value used for the filter.

Returns
@NonNullFilter

The newly created filter.

lessThanOrEqualTo

public static @NonNullFilter lessThanOrEqualTo(@NonNullFieldPath fieldPath, @NullableObject value)

Creates a new filter for checking that the given field is less than or equal to the given value.

Parameters
@NonNullFieldPath fieldPath

The field path used for the filter.

@NullableObject value

The value used for the filter.

Returns
@NonNullFilter

The newly created filter.

notEqualTo

public static @NonNullFilter notEqualTo(@NonNullString field, @NullableObject value)

Creates a new filter for checking that the given field is not equal to the given value.

Parameters
@NonNullString field

The field used for the filter.

@NullableObject value

The value used for the filter.

Returns
@NonNullFilter

The newly created filter.

notEqualTo

public static @NonNullFilter notEqualTo(@NonNullFieldPath fieldPath, @NullableObject value)

Creates a new filter for checking that the given field is not equal to the given value.

Parameters
@NonNullFieldPath fieldPath

The field path used for the filter.

@NullableObject value

The value used for the filter.

Returns
@NonNullFilter

The newly created filter.

notInArray

public static @NonNullFilter notInArray(@NonNullString field, @NonNullList<Object> values)

Creates a new filter for checking that the given field does not equal any of the given values.

Parameters
@NonNullString field

The field path used for the filter.

@NonNullList<Object> values

The list of values used for the filter.

Returns
@NonNullFilter

The newly created filter.

notInArray

public static @NonNullFilter notInArray(@NonNullFieldPath fieldPath, @NonNullList<Object> values)

Creates a new filter for checking that the given field does not equal any of the given values.

Parameters
@NonNullFieldPath fieldPath

The field path used for the filter.

@NonNullList<Object> values

The list of values used for the filter.

Returns
@NonNullFilter

The newly created filter.

or

public static @NonNullFilter or(Filter[] filters)

Creates a new filter that is a disjunction of the given filters. A disjunction filter includes a document if it satisfiesany of the given filters.

Parameters
Filter[] filters

The list of filters to perform a disjunction for.

Returns
@NonNullFilter

The newly created filter.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-07-21 UTC.