AttributeFilter - Amazon Kendra API Reference

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 OrAllFilters in combination with each other or with other operations such as EqualsTo. For example:

AndAllFilters

  • EqualsTo: "Department", "HR"

  • OrAllFilters

    • 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.

Contents

AndAllFilters

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

Type: Array of AttributeFilter objects

Required: No

ContainsAll

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

Type: DocumentAttribute object

Required: No

ContainsAny

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

Type: DocumentAttribute object

Required: No

EqualsTo

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

Type: DocumentAttribute object

Required: No

GreaterThan

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

Type: DocumentAttribute object

Required: No

GreaterThanOrEquals

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

Type: DocumentAttribute object

Required: No

LessThan

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

Type: DocumentAttribute object

Required: No

LessThanOrEquals

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

Type: DocumentAttribute object

Required: No

NotFilter

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

Type: AttributeFilter object

Required: No

OrAllFilters

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

Type: Array of AttributeFilter objects

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: