RetrievalFilter
Specifies the filters to use on the metadata attributes in the knowledge base data sources before returning results. For more information, see Query configurations. See the examples below to see how to use these filters.
This data type is used in the following API operations:
-
Retrieve request – in the
filter
field -
RetrieveAndGenerate request – in the
filter
field
Contents
Important
This data type is a UNION, so only one of the following members can be specified when used or returned.
- andAll
-
Knowledge base data sources are returned if their metadata attributes fulfill all the filter conditions inside this list.
Type: Array of RetrievalFilter objects
Array Members: Minimum number of 2 items.
Required: No
- equals
-
Knowledge base data sources are returned if they contain a metadata attribute whose name matches the
key
and whose value matches thevalue
in this object.The following example would return data sources with an
animal
attribute whose value iscat
:"equals": { "key": "animal", "value": "cat" }
Type: FilterAttribute object
Required: No
- greaterThan
-
Knowledge base data sources are returned if they contain a metadata attribute whose name matches the
key
and whose value is greater than thevalue
in this object.The following example would return data sources with an
year
attribute whose value is greater than1989
:"greaterThan": { "key": "year", "value": 1989 }
Type: FilterAttribute object
Required: No
- greaterThanOrEquals
-
Knowledge base data sources are returned if they contain a metadata attribute whose name matches the
key
and whose value is greater than or equal to thevalue
in this object.The following example would return data sources with an
year
attribute whose value is greater than or equal to1989
:"greaterThanOrEquals": { "key": "year", "value": 1989 }
Type: FilterAttribute object
Required: No
- in
-
Knowledge base data sources are returned if they contain a metadata attribute whose name matches the
key
and whose value is in the list specified in thevalue
in this object.The following example would return data sources with an
animal
attribute that is eithercat
ordog
:"in": { "key": "animal", "value": ["cat", "dog"] }
Type: FilterAttribute object
Required: No
- lessThan
-
Knowledge base data sources are returned if they contain a metadata attribute whose name matches the
key
and whose value is less than thevalue
in this object.The following example would return data sources with an
year
attribute whose value is less than to1989
."lessThan": { "key": "year", "value": 1989 }
Type: FilterAttribute object
Required: No
- lessThanOrEquals
-
Knowledge base data sources are returned if they contain a metadata attribute whose name matches the
key
and whose value is less than or equal to thevalue
in this object.The following example would return data sources with an
year
attribute whose value is less than or equal to1989
."lessThanOrEquals": { "key": "year", "value": 1989 }
Type: FilterAttribute object
Required: No
- listContains
-
Knowledge base data sources are returned if they contain a metadata attribute whose name matches the
key
and whose value is a list that contains thevalue
as one of its members.The following example would return data sources with an
animals
attribute that is a list containing acat
member (for example["dog", "cat"]
)."listContains": { "key": "animals", "value": "cat" }
Type: FilterAttribute object
Required: No
- notEquals
-
Knowledge base data sources that contain a metadata attribute whose name matches the
key
and whose value doesn't match thevalue
in this object are returned.The following example would return data sources that don't contain an
animal
attribute whose value iscat
."notEquals": { "key": "animal", "value": "cat" }
Type: FilterAttribute object
Required: No
- notIn
-
Knowledge base data sources are returned if they contain a metadata attribute whose name matches the
key
and whose value isn't in the list specified in thevalue
in this object.The following example would return data sources whose
animal
attribute is neithercat
nordog
."notIn": { "key": "animal", "value": ["cat", "dog"] }
Type: FilterAttribute object
Required: No
- orAll
-
Knowledge base data sources are returned if their metadata attributes fulfill at least one of the filter conditions inside this list.
Type: Array of RetrievalFilter objects
Array Members: Minimum number of 2 items.
Required: No
- startsWith
-
Knowledge base data sources are returned if they contain a metadata attribute whose name matches the
key
and whose value starts with thevalue
in this object. This filter is currently only supported for Amazon OpenSearch Serverless vector stores.The following example would return data sources with an
animal
attribute starts withca
(for example,cat
orcamel
)."startsWith": { "key": "animal", "value": "ca" }
Type: FilterAttribute object
Required: No
- stringContains
-
Knowledge base data sources are returned if they contain a metadata attribute whose name matches the
key
and whose value is one of the following:-
A string that contains the
value
as a substring. The following example would return data sources with ananimal
attribute that contains the substringat
(for examplecat
)."stringContains": { "key": "animal", "value": "at" }
-
A list with a member that contains the
value
as a substring. The following example would return data sources with ananimals
attribute that is a list containing a member that contains the substringat
(for example["dog", "cat"]
)."stringContains": { "key": "animals", "value": "at" }
Type: FilterAttribute object
Required: No
-
See Also
For more information about using this API in one of the language-specific AWS SDKs, see the following: