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
Properties
Performs a logical AND
operation on all filters that you specify.
Returns true when a document contains all of the specified document attributes/fields. This filter is only applicable to StringListValue.
Returns true when a document contains any of the specified document attributes/fields. This filter is only applicable to StringListValue.
Performs an equals operation on document attributes/fields and their values.
Performs a greater than operation on document attributes/fields and their values. Use with the document attribute typeDate
or Long
.
Performs a greater or equals than operation on document attributes/fields and their values. Use with the document attribute typeDate
or Long
.
Performs a less than operation on document attributes/fields and their values. Use with the document attribute typeDate
or Long
.
Performs a less than or equals operation on document attributes/fields and their values. Use with the document attribute typeDate
or Long
.
Performs a logical NOT
operation on all filters that you specify.
Performs a logical OR
operation on all filters that you specify.