aws_sdk_kendra/operation/retrieve/
builders.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2pub use crate::operation::retrieve::_retrieve_output::RetrieveOutputBuilder;
3
4pub use crate::operation::retrieve::_retrieve_input::RetrieveInputBuilder;
5
6impl crate::operation::retrieve::builders::RetrieveInputBuilder {
7    /// Sends a request with this input using the given client.
8    pub async fn send_with(
9        self,
10        client: &crate::Client,
11    ) -> ::std::result::Result<
12        crate::operation::retrieve::RetrieveOutput,
13        ::aws_smithy_runtime_api::client::result::SdkError<
14            crate::operation::retrieve::RetrieveError,
15            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
16        >,
17    > {
18        let mut fluent_builder = client.retrieve();
19        fluent_builder.inner = self;
20        fluent_builder.send().await
21    }
22}
23/// Fluent builder constructing a request to `Retrieve`.
24///
25/// <p>Retrieves relevant passages or text excerpts given an input query.</p>
26/// <p>This API is similar to the <a href="https://docs.aws.amazon.com/kendra/latest/APIReference/API_Query.html">Query</a> API. However, by default, the <code>Query</code> API only returns excerpt passages of up to 100 token words. With the <code>Retrieve</code> 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 <code>Retrieve</code> API, you can alternatively use the <code>Query</code> API and its types of responses.</p>
27/// <p>You can also do the following:</p>
28/// <ul>
29/// <li>
30/// <p>Override boosting at the index level</p></li>
31/// <li>
32/// <p>Filter based on document fields or attributes</p></li>
33/// <li>
34/// <p>Filter based on the user or their group access to documents</p></li>
35/// <li>
36/// <p>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.</p><note>
37/// <p>Confidence score buckets are currently available only for English.</p>
38/// </note></li>
39/// </ul>
40/// <p>You can also include certain fields in the response that might provide useful additional information.</p>
41/// <p>The <code>Retrieve</code> API shares the number of <a href="https://docs.aws.amazon.com/kendra/latest/APIReference/API_CapacityUnitsConfiguration.html">query capacity units</a> 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 <a href="https://docs.aws.amazon.com/kendra/latest/dg/adjusting-capacity.html">Adjusting capacity</a>.</p><important>
42/// <p>If you're using an Amazon Kendra Gen AI Enterprise Edition index, you can only use <code>ATTRIBUTE_FILTER</code> to filter search results by user context. If you're using an Amazon Kendra Gen AI Enterprise Edition index and you try to use <code>USER_TOKEN</code> to configure user context policy, Amazon Kendra returns a <code>ValidationException</code> error.</p>
43/// </important>
44#[derive(::std::clone::Clone, ::std::fmt::Debug)]
45pub struct RetrieveFluentBuilder {
46    handle: ::std::sync::Arc<crate::client::Handle>,
47    inner: crate::operation::retrieve::builders::RetrieveInputBuilder,
48    config_override: ::std::option::Option<crate::config::Builder>,
49}
50impl crate::client::customize::internal::CustomizableSend<crate::operation::retrieve::RetrieveOutput, crate::operation::retrieve::RetrieveError>
51    for RetrieveFluentBuilder
52{
53    fn send(
54        self,
55        config_override: crate::config::Builder,
56    ) -> crate::client::customize::internal::BoxFuture<
57        crate::client::customize::internal::SendResult<crate::operation::retrieve::RetrieveOutput, crate::operation::retrieve::RetrieveError>,
58    > {
59        ::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
60    }
61}
62impl RetrieveFluentBuilder {
63    /// Creates a new `RetrieveFluentBuilder`.
64    pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
65        Self {
66            handle,
67            inner: ::std::default::Default::default(),
68            config_override: ::std::option::Option::None,
69        }
70    }
71    /// Access the Retrieve as a reference.
72    pub fn as_input(&self) -> &crate::operation::retrieve::builders::RetrieveInputBuilder {
73        &self.inner
74    }
75    /// Sends the request and returns the response.
76    ///
77    /// If an error occurs, an `SdkError` will be returned with additional details that
78    /// can be matched against.
79    ///
80    /// By default, any retryable failures will be retried twice. Retry behavior
81    /// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
82    /// set when configuring the client.
83    pub async fn send(
84        self,
85    ) -> ::std::result::Result<
86        crate::operation::retrieve::RetrieveOutput,
87        ::aws_smithy_runtime_api::client::result::SdkError<
88            crate::operation::retrieve::RetrieveError,
89            ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
90        >,
91    > {
92        let input = self
93            .inner
94            .build()
95            .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
96        let runtime_plugins = crate::operation::retrieve::Retrieve::operation_runtime_plugins(
97            self.handle.runtime_plugins.clone(),
98            &self.handle.conf,
99            self.config_override,
100        );
101        crate::operation::retrieve::Retrieve::orchestrate(&runtime_plugins, input).await
102    }
103
104    /// Consumes this builder, creating a customizable operation that can be modified before being sent.
105    pub fn customize(
106        self,
107    ) -> crate::client::customize::CustomizableOperation<crate::operation::retrieve::RetrieveOutput, crate::operation::retrieve::RetrieveError, Self>
108    {
109        crate::client::customize::CustomizableOperation::new(self)
110    }
111    pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
112        self.set_config_override(::std::option::Option::Some(config_override.into()));
113        self
114    }
115
116    pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
117        self.config_override = config_override;
118        self
119    }
120    /// <p>The identifier of the index to retrieve relevant passages for the search.</p>
121    pub fn index_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
122        self.inner = self.inner.index_id(input.into());
123        self
124    }
125    /// <p>The identifier of the index to retrieve relevant passages for the search.</p>
126    pub fn set_index_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
127        self.inner = self.inner.set_index_id(input);
128        self
129    }
130    /// <p>The identifier of the index to retrieve relevant passages for the search.</p>
131    pub fn get_index_id(&self) -> &::std::option::Option<::std::string::String> {
132        self.inner.get_index_id()
133    }
134    /// <p>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, <code>Timeoff AND October AND Category:HR</code> is counted as 3 tokens: <code>timeoff</code>, <code>october</code>, <code>hr</code>. For more information, see <a href="https://docs.aws.amazon.com/kendra/latest/dg/searching-example.html#searching-index-query-syntax">Searching with advanced query syntax</a> in the Amazon Kendra Developer Guide.</p>
135    pub fn query_text(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
136        self.inner = self.inner.query_text(input.into());
137        self
138    }
139    /// <p>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, <code>Timeoff AND October AND Category:HR</code> is counted as 3 tokens: <code>timeoff</code>, <code>october</code>, <code>hr</code>. For more information, see <a href="https://docs.aws.amazon.com/kendra/latest/dg/searching-example.html#searching-index-query-syntax">Searching with advanced query syntax</a> in the Amazon Kendra Developer Guide.</p>
140    pub fn set_query_text(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
141        self.inner = self.inner.set_query_text(input);
142        self
143    }
144    /// <p>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, <code>Timeoff AND October AND Category:HR</code> is counted as 3 tokens: <code>timeoff</code>, <code>october</code>, <code>hr</code>. For more information, see <a href="https://docs.aws.amazon.com/kendra/latest/dg/searching-example.html#searching-index-query-syntax">Searching with advanced query syntax</a> in the Amazon Kendra Developer Guide.</p>
145    pub fn get_query_text(&self) -> &::std::option::Option<::std::string::String> {
146        self.inner.get_query_text()
147    }
148    /// <p>Filters search results by document fields/attributes. You can only provide one attribute filter; however, the <code>AndAllFilters</code>, <code>NotFilter</code>, and <code>OrAllFilters</code> parameters contain a list of other filters.</p>
149    /// <p>The <code>AttributeFilter</code> parameter means you can create a set of filtering rules that a document must satisfy to be included in the query results.</p><note>
150    /// <p>For Amazon Kendra Gen AI Enterprise Edition indices use <code>AttributeFilter</code> to enable document filtering for end users using <code>_email_id</code> or include public documents (<code>_email_id=null</code>).</p>
151    /// </note>
152    pub fn attribute_filter(mut self, input: crate::types::AttributeFilter) -> Self {
153        self.inner = self.inner.attribute_filter(input);
154        self
155    }
156    /// <p>Filters search results by document fields/attributes. You can only provide one attribute filter; however, the <code>AndAllFilters</code>, <code>NotFilter</code>, and <code>OrAllFilters</code> parameters contain a list of other filters.</p>
157    /// <p>The <code>AttributeFilter</code> parameter means you can create a set of filtering rules that a document must satisfy to be included in the query results.</p><note>
158    /// <p>For Amazon Kendra Gen AI Enterprise Edition indices use <code>AttributeFilter</code> to enable document filtering for end users using <code>_email_id</code> or include public documents (<code>_email_id=null</code>).</p>
159    /// </note>
160    pub fn set_attribute_filter(mut self, input: ::std::option::Option<crate::types::AttributeFilter>) -> Self {
161        self.inner = self.inner.set_attribute_filter(input);
162        self
163    }
164    /// <p>Filters search results by document fields/attributes. You can only provide one attribute filter; however, the <code>AndAllFilters</code>, <code>NotFilter</code>, and <code>OrAllFilters</code> parameters contain a list of other filters.</p>
165    /// <p>The <code>AttributeFilter</code> parameter means you can create a set of filtering rules that a document must satisfy to be included in the query results.</p><note>
166    /// <p>For Amazon Kendra Gen AI Enterprise Edition indices use <code>AttributeFilter</code> to enable document filtering for end users using <code>_email_id</code> or include public documents (<code>_email_id=null</code>).</p>
167    /// </note>
168    pub fn get_attribute_filter(&self) -> &::std::option::Option<crate::types::AttributeFilter> {
169        self.inner.get_attribute_filter()
170    }
171    ///
172    /// Appends an item to `RequestedDocumentAttributes`.
173    ///
174    /// To override the contents of this collection use [`set_requested_document_attributes`](Self::set_requested_document_attributes).
175    ///
176    /// <p>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.</p>
177    pub fn requested_document_attributes(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
178        self.inner = self.inner.requested_document_attributes(input.into());
179        self
180    }
181    /// <p>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.</p>
182    pub fn set_requested_document_attributes(mut self, input: ::std::option::Option<::std::vec::Vec<::std::string::String>>) -> Self {
183        self.inner = self.inner.set_requested_document_attributes(input);
184        self
185    }
186    /// <p>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.</p>
187    pub fn get_requested_document_attributes(&self) -> &::std::option::Option<::std::vec::Vec<::std::string::String>> {
188        self.inner.get_requested_document_attributes()
189    }
190    ///
191    /// Appends an item to `DocumentRelevanceOverrideConfigurations`.
192    ///
193    /// To override the contents of this collection use [`set_document_relevance_override_configurations`](Self::set_document_relevance_override_configurations).
194    ///
195    /// <p>Overrides relevance tuning configurations of fields/attributes set at the index level.</p>
196    /// <p>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.</p>
197    /// <p>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.</p>
198    pub fn document_relevance_override_configurations(mut self, input: crate::types::DocumentRelevanceConfiguration) -> Self {
199        self.inner = self.inner.document_relevance_override_configurations(input);
200        self
201    }
202    /// <p>Overrides relevance tuning configurations of fields/attributes set at the index level.</p>
203    /// <p>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.</p>
204    /// <p>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.</p>
205    pub fn set_document_relevance_override_configurations(
206        mut self,
207        input: ::std::option::Option<::std::vec::Vec<crate::types::DocumentRelevanceConfiguration>>,
208    ) -> Self {
209        self.inner = self.inner.set_document_relevance_override_configurations(input);
210        self
211    }
212    /// <p>Overrides relevance tuning configurations of fields/attributes set at the index level.</p>
213    /// <p>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.</p>
214    /// <p>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.</p>
215    pub fn get_document_relevance_override_configurations(
216        &self,
217    ) -> &::std::option::Option<::std::vec::Vec<crate::types::DocumentRelevanceConfiguration>> {
218        self.inner.get_document_relevance_override_configurations()
219    }
220    /// <p>Retrieved relevant passages are returned in pages the size of the <code>PageSize</code> parameter. By default, Amazon Kendra returns the first page of results. Use this parameter to get result pages after the first one.</p>
221    pub fn page_number(mut self, input: i32) -> Self {
222        self.inner = self.inner.page_number(input);
223        self
224    }
225    /// <p>Retrieved relevant passages are returned in pages the size of the <code>PageSize</code> parameter. By default, Amazon Kendra returns the first page of results. Use this parameter to get result pages after the first one.</p>
226    pub fn set_page_number(mut self, input: ::std::option::Option<i32>) -> Self {
227        self.inner = self.inner.set_page_number(input);
228        self
229    }
230    /// <p>Retrieved relevant passages are returned in pages the size of the <code>PageSize</code> parameter. By default, Amazon Kendra returns the first page of results. Use this parameter to get result pages after the first one.</p>
231    pub fn get_page_number(&self) -> &::std::option::Option<i32> {
232        self.inner.get_page_number()
233    }
234    /// <p>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.</p>
235    pub fn page_size(mut self, input: i32) -> Self {
236        self.inner = self.inner.page_size(input);
237        self
238    }
239    /// <p>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.</p>
240    pub fn set_page_size(mut self, input: ::std::option::Option<i32>) -> Self {
241        self.inner = self.inner.set_page_size(input);
242        self
243    }
244    /// <p>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.</p>
245    pub fn get_page_size(&self) -> &::std::option::Option<i32> {
246        self.inner.get_page_size()
247    }
248    /// <p>The user context token or user and group information.</p>
249    pub fn user_context(mut self, input: crate::types::UserContext) -> Self {
250        self.inner = self.inner.user_context(input);
251        self
252    }
253    /// <p>The user context token or user and group information.</p>
254    pub fn set_user_context(mut self, input: ::std::option::Option<crate::types::UserContext>) -> Self {
255        self.inner = self.inner.set_user_context(input);
256        self
257    }
258    /// <p>The user context token or user and group information.</p>
259    pub fn get_user_context(&self) -> &::std::option::Option<crate::types::UserContext> {
260        self.inner.get_user_context()
261    }
262}