Retrieve
kendra_retrieve | R Documentation |
Retrieves relevant passages or text excerpts given an input query¶
Description¶
Retrieves relevant passages or text excerpts given an input query.
This API is similar to the query
API. However, by default, the query
API only returns excerpt passages of up to 100 token words. With the
retrieve
API, you can retrieve longer passages of up to 200 token
words and up to 100 semantically relevant passages. This doesn't include
question-answer or FAQ type responses from your index. The passages are
text excerpts that can be semantically extracted from multiple documents
and multiple parts of the same document. If in extreme cases your
documents produce zero passages using the retrieve
API, you can
alternatively use the query
API and its types of responses.
You can also do the following:
-
Override boosting at the index level
-
Filter based on document fields or attributes
-
Filter based on the user or their group access to documents
-
View the confidence score bucket for a retrieved passage result. The confidence bucket provides a relative ranking that indicates how confident Amazon Kendra is that the response is relevant to the query.
Confidence score buckets are currently available only for English.
You can also include certain fields in the response that might provide useful additional information.
The retrieve
API shares the number of query capacity
units
that you set for your index. For more information on what's included in
a single capacity unit and the default base capacity for an index, see
Adjusting
capacity.
If you're using an Amazon Kendra Gen AI Enterprise Edition index, you
can only use ATTRIBUTE_FILTER
to filter search results by user
context. If you're using an Amazon Kendra Gen AI Enterprise Edition
index and you try to use USER_TOKEN
to configure user context policy,
Amazon Kendra returns a ValidationException
error.
Usage¶
kendra_retrieve(IndexId, QueryText, AttributeFilter,
RequestedDocumentAttributes, DocumentRelevanceOverrideConfigurations,
PageNumber, PageSize, UserContext)
Arguments¶
IndexId |
[required] The identifier of the index to retrieve relevant passages for the search. |
QueryText |
[required] The input query text to retrieve relevant passages for
the search. Amazon Kendra truncates queries at 30 token words, which
excludes punctuation and stop words. Truncation still applies if you use
Boolean or more advanced, complex queries. For example, |
AttributeFilter |
Filters search results by document fields/attributes. You can
only provide one attribute filter; however, the
The For Amazon Kendra Gen AI Enterprise Edition indices use
|
RequestedDocumentAttributes |
A list of document fields/attributes to include in the response. You can limit the response to include certain document fields. By default, all document fields are included in the response. |
DocumentRelevanceOverrideConfigurations |
Overrides relevance tuning configurations of fields/attributes set at the index level. If you use this API to override the relevance tuning configured at the index level, but there is no relevance tuning configured at the index level, then Amazon Kendra does not apply any relevance tuning. If there is relevance tuning configured for fields at the index level, and you use this API to override only some of these fields, then for the fields you did not override, the importance is set to 1. |
PageNumber |
Retrieved relevant passages are returned in pages the size of the
|
PageSize |
Sets the number of retrieved relevant passages that are returned in each page of results. The default page size is 10. The maximum number of results returned is 100. If you ask for more than 100 results, only 100 are returned. |
UserContext |
The user context token or user and group information. |
Value¶
A list with the following syntax:
list(
QueryId = "string",
ResultItems = list(
list(
Id = "string",
DocumentId = "string",
DocumentTitle = "string",
Content = "string",
DocumentURI = "string",
DocumentAttributes = list(
list(
Key = "string",
Value = list(
StringValue = "string",
StringListValue = list(
"string"
),
LongValue = 123,
DateValue = as.POSIXct(
"2015-01-01"
)
)
)
),
ScoreAttributes = list(
ScoreConfidence = "VERY_HIGH"|"HIGH"|"MEDIUM"|"LOW"|"NOT_AVAILABLE"
)
)
)
)
Request syntax¶
svc$retrieve(
IndexId = "string",
QueryText = "string",
AttributeFilter = list(
AndAllFilters = list(
list()
),
OrAllFilters = list(
list()
),
NotFilter = list(),
EqualsTo = list(
Key = "string",
Value = list(
StringValue = "string",
StringListValue = list(
"string"
),
LongValue = 123,
DateValue = as.POSIXct(
"2015-01-01"
)
)
),
ContainsAll = list(
Key = "string",
Value = list(
StringValue = "string",
StringListValue = list(
"string"
),
LongValue = 123,
DateValue = as.POSIXct(
"2015-01-01"
)
)
),
ContainsAny = list(
Key = "string",
Value = list(
StringValue = "string",
StringListValue = list(
"string"
),
LongValue = 123,
DateValue = as.POSIXct(
"2015-01-01"
)
)
),
GreaterThan = list(
Key = "string",
Value = list(
StringValue = "string",
StringListValue = list(
"string"
),
LongValue = 123,
DateValue = as.POSIXct(
"2015-01-01"
)
)
),
GreaterThanOrEquals = list(
Key = "string",
Value = list(
StringValue = "string",
StringListValue = list(
"string"
),
LongValue = 123,
DateValue = as.POSIXct(
"2015-01-01"
)
)
),
LessThan = list(
Key = "string",
Value = list(
StringValue = "string",
StringListValue = list(
"string"
),
LongValue = 123,
DateValue = as.POSIXct(
"2015-01-01"
)
)
),
LessThanOrEquals = list(
Key = "string",
Value = list(
StringValue = "string",
StringListValue = list(
"string"
),
LongValue = 123,
DateValue = as.POSIXct(
"2015-01-01"
)
)
)
),
RequestedDocumentAttributes = list(
"string"
),
DocumentRelevanceOverrideConfigurations = list(
list(
Name = "string",
Relevance = list(
Freshness = TRUE|FALSE,
Importance = 123,
Duration = "string",
RankOrder = "ASCENDING"|"DESCENDING",
ValueImportanceMap = list(
123
)
)
)
),
PageNumber = 123,
PageSize = 123,
UserContext = list(
Token = "string",
UserId = "string",
Groups = list(
"string"
),
DataSourceGroups = list(
list(
GroupId = "string",
DataSourceId = "string"
)
)
)
)