AttributeFilter

Filters the search results based on document attributes or fields.

You can filter results using attributes for your particular documents. The attributes must exist in your index. For example, if your documents include the custom attribute "Department", you can filter documents that belong to the "HR" department. You would use the EqualsTo operation to filter results or documents with "Department" equals to "HR".

You can use AndAllFilters and AndOrFilters in combination with each other or with other operations such as EqualsTo. For example:

AndAllFilters

  • EqualsTo: "Department", "HR"

  • AndOrFilters

    • ContainsAny: "Project Name", ["new hires", "new hiring"]

This example filters results or documents that belong to the HR department and belong to projects that contain "new hires" or "new hiring" in the project name (must use ContainAny with StringListValue). This example is filtering with a depth of 2.

You cannot filter more than a depth of 2, otherwise you receive a ValidationException exception with the message "AttributeFilter cannot have a depth of more than 2." Also, if you use more than 10 attribute filters in a given list for AndAllFilters or OrAllFilters, you receive a ValidationException with the message "AttributeFilter cannot have a length of more than 10".

For examples of using AttributeFilter, see Using document attributes to filter search results.

Types

Link copied to clipboard
class Builder
Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Performs a logical AND operation on all filters that you specify.

Link copied to clipboard

Returns true when a document contains all of the specified document attributes/fields. This filter is only applicable to StringListValue.

Link copied to clipboard

Returns true when a document contains any of the specified document attributes/fields. This filter is only applicable to StringListValue.

Link copied to clipboard

Performs an equals operation on document attributes/fields and their values.

Link copied to clipboard

Performs a greater than operation on document attributes/fields and their values. Use with the document attribute typeDate or Long.

Link copied to clipboard

Performs a greater or equals than operation on document attributes/fields and their values. Use with the document attribute typeDate or Long.

Link copied to clipboard

Performs a less than operation on document attributes/fields and their values. Use with the document attribute typeDate or Long.

Link copied to clipboard

Performs a less than or equals operation on document attributes/fields and their values. Use with the document attribute typeDate or Long.

Link copied to clipboard

Performs a logical NOT operation on all filters that you specify.

Link copied to clipboard

Performs a logical OR operation on all filters that you specify.

Functions

Link copied to clipboard
inline fun copy(block: AttributeFilter.Builder.() -> Unit = {}): AttributeFilter
Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open override fun toString(): String