1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub use crate::operation::query::_query_output::QueryOutputBuilder;
pub use crate::operation::query::_query_input::QueryInputBuilder;
impl crate::operation::query::builders::QueryInputBuilder {
/// Sends a request with this input using the given client.
pub async fn send_with(
self,
client: &crate::Client,
) -> ::std::result::Result<
crate::operation::query::QueryOutput,
::aws_smithy_runtime_api::client::result::SdkError<
crate::operation::query::QueryError,
::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
>,
> {
let mut fluent_builder = client.query();
fluent_builder.inner = self;
fluent_builder.send().await
}
}
/// Fluent builder constructing a request to `Query`.
///
/// <p>Searches an index given an input query.</p><note>
/// <p>If you are working with large language models (LLMs) or implementing retrieval augmented generation (RAG) systems, you can use Amazon Kendra's <a href="https://docs.aws.amazon.com/kendra/latest/APIReference/API_Retrieve.html">Retrieve</a> API, which can return longer semantically relevant passages. We recommend using the <code>Retrieve</code> API instead of filing a service limit increase to increase the <code>Query</code> API document excerpt length.</p>
/// </note>
/// <p>You can configure boosting or relevance tuning at the query level to override boosting at the index level, filter based on document fields/attributes and faceted search, and filter based on the user or their group access to documents. You can also include certain fields in the response that might provide useful additional information.</p>
/// <p>A query response contains three types of results.</p>
/// <ul>
/// <li>
/// <p>Relevant suggested answers. The answers can be either a text excerpt or table excerpt. The answer can be highlighted in the excerpt.</p></li>
/// <li>
/// <p>Matching FAQs or questions-answer from your FAQ file.</p></li>
/// <li>
/// <p>Relevant documents. This result type includes an excerpt of the document with the document title. The searched terms can be highlighted in the excerpt.</p></li>
/// </ul>
/// <p>You can specify that the query return only one type of result using the <code>QueryResultTypeFilter</code> parameter. Each query returns the 100 most relevant results. If you filter result type to only question-answers, a maximum of four results are returned. If you filter result type to only answers, a maximum of three results are returned.</p>
#[derive(::std::clone::Clone, ::std::fmt::Debug)]
pub struct QueryFluentBuilder {
handle: ::std::sync::Arc<crate::client::Handle>,
inner: crate::operation::query::builders::QueryInputBuilder,
config_override: ::std::option::Option<crate::config::Builder>,
}
impl crate::client::customize::internal::CustomizableSend<crate::operation::query::QueryOutput, crate::operation::query::QueryError>
for QueryFluentBuilder
{
fn send(
self,
config_override: crate::config::Builder,
) -> crate::client::customize::internal::BoxFuture<
crate::client::customize::internal::SendResult<crate::operation::query::QueryOutput, crate::operation::query::QueryError>,
> {
::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
}
}
impl QueryFluentBuilder {
/// Creates a new `QueryFluentBuilder`.
pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
Self {
handle,
inner: ::std::default::Default::default(),
config_override: ::std::option::Option::None,
}
}
/// Access the Query as a reference.
pub fn as_input(&self) -> &crate::operation::query::builders::QueryInputBuilder {
&self.inner
}
/// Sends the request and returns the response.
///
/// If an error occurs, an `SdkError` will be returned with additional details that
/// can be matched against.
///
/// By default, any retryable failures will be retried twice. Retry behavior
/// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
/// set when configuring the client.
pub async fn send(
self,
) -> ::std::result::Result<
crate::operation::query::QueryOutput,
::aws_smithy_runtime_api::client::result::SdkError<
crate::operation::query::QueryError,
::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
>,
> {
let input = self
.inner
.build()
.map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
let runtime_plugins =
crate::operation::query::Query::operation_runtime_plugins(self.handle.runtime_plugins.clone(), &self.handle.conf, self.config_override);
crate::operation::query::Query::orchestrate(&runtime_plugins, input).await
}
/// Consumes this builder, creating a customizable operation that can be modified before being sent.
pub fn customize(
self,
) -> crate::client::customize::CustomizableOperation<crate::operation::query::QueryOutput, crate::operation::query::QueryError, Self> {
crate::client::customize::CustomizableOperation::new(self)
}
pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
self.set_config_override(::std::option::Option::Some(config_override.into()));
self
}
pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
self.config_override = config_override;
self
}
/// <p>The identifier of the index for the search.</p>
pub fn index_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
self.inner = self.inner.index_id(input.into());
self
}
/// <p>The identifier of the index for the search.</p>
pub fn set_index_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
self.inner = self.inner.set_index_id(input);
self
}
/// <p>The identifier of the index for the search.</p>
pub fn get_index_id(&self) -> &::std::option::Option<::std::string::String> {
self.inner.get_index_id()
}
/// <p>The input query text 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>
pub fn query_text(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
self.inner = self.inner.query_text(input.into());
self
}
/// <p>The input query text 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>
pub fn set_query_text(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
self.inner = self.inner.set_query_text(input);
self
}
/// <p>The input query text 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>
pub fn get_query_text(&self) -> &::std::option::Option<::std::string::String> {
self.inner.get_query_text()
}
/// <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>
/// <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>
pub fn attribute_filter(mut self, input: crate::types::AttributeFilter) -> Self {
self.inner = self.inner.attribute_filter(input);
self
}
/// <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>
/// <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>
pub fn set_attribute_filter(mut self, input: ::std::option::Option<crate::types::AttributeFilter>) -> Self {
self.inner = self.inner.set_attribute_filter(input);
self
}
/// <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>
/// <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>
pub fn get_attribute_filter(&self) -> &::std::option::Option<crate::types::AttributeFilter> {
self.inner.get_attribute_filter()
}
///
/// Appends an item to `Facets`.
///
/// To override the contents of this collection use [`set_facets`](Self::set_facets).
///
/// <p>An array of documents fields/attributes for faceted search. Amazon Kendra returns a count for each field key specified. This helps your users narrow their search.</p>
pub fn facets(mut self, input: crate::types::Facet) -> Self {
self.inner = self.inner.facets(input);
self
}
/// <p>An array of documents fields/attributes for faceted search. Amazon Kendra returns a count for each field key specified. This helps your users narrow their search.</p>
pub fn set_facets(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::Facet>>) -> Self {
self.inner = self.inner.set_facets(input);
self
}
/// <p>An array of documents fields/attributes for faceted search. Amazon Kendra returns a count for each field key specified. This helps your users narrow their search.</p>
pub fn get_facets(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::Facet>> {
self.inner.get_facets()
}
///
/// Appends an item to `RequestedDocumentAttributes`.
///
/// To override the contents of this collection use [`set_requested_document_attributes`](Self::set_requested_document_attributes).
///
/// <p>An array of document fields/attributes to include in the response. You can limit the response to include certain document fields. By default, all document attributes are included in the response.</p>
pub fn requested_document_attributes(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
self.inner = self.inner.requested_document_attributes(input.into());
self
}
/// <p>An array of document fields/attributes to include in the response. You can limit the response to include certain document fields. By default, all document attributes are included in the response.</p>
pub fn set_requested_document_attributes(mut self, input: ::std::option::Option<::std::vec::Vec<::std::string::String>>) -> Self {
self.inner = self.inner.set_requested_document_attributes(input);
self
}
/// <p>An array of document fields/attributes to include in the response. You can limit the response to include certain document fields. By default, all document attributes are included in the response.</p>
pub fn get_requested_document_attributes(&self) -> &::std::option::Option<::std::vec::Vec<::std::string::String>> {
self.inner.get_requested_document_attributes()
}
/// <p>Sets the type of query result or response. Only results for the specified type are returned.</p>
pub fn query_result_type_filter(mut self, input: crate::types::QueryResultType) -> Self {
self.inner = self.inner.query_result_type_filter(input);
self
}
/// <p>Sets the type of query result or response. Only results for the specified type are returned.</p>
pub fn set_query_result_type_filter(mut self, input: ::std::option::Option<crate::types::QueryResultType>) -> Self {
self.inner = self.inner.set_query_result_type_filter(input);
self
}
/// <p>Sets the type of query result or response. Only results for the specified type are returned.</p>
pub fn get_query_result_type_filter(&self) -> &::std::option::Option<crate::types::QueryResultType> {
self.inner.get_query_result_type_filter()
}
///
/// Appends an item to `DocumentRelevanceOverrideConfigurations`.
///
/// To override the contents of this collection use [`set_document_relevance_override_configurations`](Self::set_document_relevance_override_configurations).
///
/// <p>Overrides relevance tuning configurations of fields/attributes set at the index level.</p>
/// <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>
/// <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>
pub fn document_relevance_override_configurations(mut self, input: crate::types::DocumentRelevanceConfiguration) -> Self {
self.inner = self.inner.document_relevance_override_configurations(input);
self
}
/// <p>Overrides relevance tuning configurations of fields/attributes set at the index level.</p>
/// <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>
/// <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>
pub fn set_document_relevance_override_configurations(
mut self,
input: ::std::option::Option<::std::vec::Vec<crate::types::DocumentRelevanceConfiguration>>,
) -> Self {
self.inner = self.inner.set_document_relevance_override_configurations(input);
self
}
/// <p>Overrides relevance tuning configurations of fields/attributes set at the index level.</p>
/// <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>
/// <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>
pub fn get_document_relevance_override_configurations(
&self,
) -> &::std::option::Option<::std::vec::Vec<crate::types::DocumentRelevanceConfiguration>> {
self.inner.get_document_relevance_override_configurations()
}
/// <p>Query results 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>
pub fn page_number(mut self, input: i32) -> Self {
self.inner = self.inner.page_number(input);
self
}
/// <p>Query results 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>
pub fn set_page_number(mut self, input: ::std::option::Option<i32>) -> Self {
self.inner = self.inner.set_page_number(input);
self
}
/// <p>Query results 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>
pub fn get_page_number(&self) -> &::std::option::Option<i32> {
self.inner.get_page_number()
}
/// <p>Sets the number of results 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>
pub fn page_size(mut self, input: i32) -> Self {
self.inner = self.inner.page_size(input);
self
}
/// <p>Sets the number of results 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>
pub fn set_page_size(mut self, input: ::std::option::Option<i32>) -> Self {
self.inner = self.inner.set_page_size(input);
self
}
/// <p>Sets the number of results 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>
pub fn get_page_size(&self) -> &::std::option::Option<i32> {
self.inner.get_page_size()
}
/// <p>Provides information that determines how the results of the query are sorted. You can set the field that Amazon Kendra should sort the results on, and specify whether the results should be sorted in ascending or descending order. In the case of ties in sorting the results, the results are sorted by relevance.</p>
/// <p>If you don't provide sorting configuration, the results are sorted by the relevance that Amazon Kendra determines for the result.</p>
pub fn sorting_configuration(mut self, input: crate::types::SortingConfiguration) -> Self {
self.inner = self.inner.sorting_configuration(input);
self
}
/// <p>Provides information that determines how the results of the query are sorted. You can set the field that Amazon Kendra should sort the results on, and specify whether the results should be sorted in ascending or descending order. In the case of ties in sorting the results, the results are sorted by relevance.</p>
/// <p>If you don't provide sorting configuration, the results are sorted by the relevance that Amazon Kendra determines for the result.</p>
pub fn set_sorting_configuration(mut self, input: ::std::option::Option<crate::types::SortingConfiguration>) -> Self {
self.inner = self.inner.set_sorting_configuration(input);
self
}
/// <p>Provides information that determines how the results of the query are sorted. You can set the field that Amazon Kendra should sort the results on, and specify whether the results should be sorted in ascending or descending order. In the case of ties in sorting the results, the results are sorted by relevance.</p>
/// <p>If you don't provide sorting configuration, the results are sorted by the relevance that Amazon Kendra determines for the result.</p>
pub fn get_sorting_configuration(&self) -> &::std::option::Option<crate::types::SortingConfiguration> {
self.inner.get_sorting_configuration()
}
///
/// Appends an item to `SortingConfigurations`.
///
/// To override the contents of this collection use [`set_sorting_configurations`](Self::set_sorting_configurations).
///
/// <p>Provides configuration information to determine how the results of a query are sorted.</p>
/// <p>You can set upto 3 fields that Amazon Kendra should sort the results on, and specify whether the results should be sorted in ascending or descending order. The sort field quota can be increased.</p>
/// <p>If you don't provide a sorting configuration, the results are sorted by the relevance that Amazon Kendra determines for the result. In the case of ties in sorting the results, the results are sorted by relevance.</p>
pub fn sorting_configurations(mut self, input: crate::types::SortingConfiguration) -> Self {
self.inner = self.inner.sorting_configurations(input);
self
}
/// <p>Provides configuration information to determine how the results of a query are sorted.</p>
/// <p>You can set upto 3 fields that Amazon Kendra should sort the results on, and specify whether the results should be sorted in ascending or descending order. The sort field quota can be increased.</p>
/// <p>If you don't provide a sorting configuration, the results are sorted by the relevance that Amazon Kendra determines for the result. In the case of ties in sorting the results, the results are sorted by relevance.</p>
pub fn set_sorting_configurations(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::SortingConfiguration>>) -> Self {
self.inner = self.inner.set_sorting_configurations(input);
self
}
/// <p>Provides configuration information to determine how the results of a query are sorted.</p>
/// <p>You can set upto 3 fields that Amazon Kendra should sort the results on, and specify whether the results should be sorted in ascending or descending order. The sort field quota can be increased.</p>
/// <p>If you don't provide a sorting configuration, the results are sorted by the relevance that Amazon Kendra determines for the result. In the case of ties in sorting the results, the results are sorted by relevance.</p>
pub fn get_sorting_configurations(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::SortingConfiguration>> {
self.inner.get_sorting_configurations()
}
/// <p>The user context token or user and group information.</p>
pub fn user_context(mut self, input: crate::types::UserContext) -> Self {
self.inner = self.inner.user_context(input);
self
}
/// <p>The user context token or user and group information.</p>
pub fn set_user_context(mut self, input: ::std::option::Option<crate::types::UserContext>) -> Self {
self.inner = self.inner.set_user_context(input);
self
}
/// <p>The user context token or user and group information.</p>
pub fn get_user_context(&self) -> &::std::option::Option<crate::types::UserContext> {
self.inner.get_user_context()
}
/// <p>Provides an identifier for a specific user. The <code>VisitorId</code> should be a unique identifier, such as a GUID. Don't use personally identifiable information, such as the user's email address, as the <code>VisitorId</code>.</p>
pub fn visitor_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
self.inner = self.inner.visitor_id(input.into());
self
}
/// <p>Provides an identifier for a specific user. The <code>VisitorId</code> should be a unique identifier, such as a GUID. Don't use personally identifiable information, such as the user's email address, as the <code>VisitorId</code>.</p>
pub fn set_visitor_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
self.inner = self.inner.set_visitor_id(input);
self
}
/// <p>Provides an identifier for a specific user. The <code>VisitorId</code> should be a unique identifier, such as a GUID. Don't use personally identifiable information, such as the user's email address, as the <code>VisitorId</code>.</p>
pub fn get_visitor_id(&self) -> &::std::option::Option<::std::string::String> {
self.inner.get_visitor_id()
}
/// <p>Enables suggested spell corrections for queries.</p>
pub fn spell_correction_configuration(mut self, input: crate::types::SpellCorrectionConfiguration) -> Self {
self.inner = self.inner.spell_correction_configuration(input);
self
}
/// <p>Enables suggested spell corrections for queries.</p>
pub fn set_spell_correction_configuration(mut self, input: ::std::option::Option<crate::types::SpellCorrectionConfiguration>) -> Self {
self.inner = self.inner.set_spell_correction_configuration(input);
self
}
/// <p>Enables suggested spell corrections for queries.</p>
pub fn get_spell_correction_configuration(&self) -> &::std::option::Option<crate::types::SpellCorrectionConfiguration> {
self.inner.get_spell_correction_configuration()
}
/// <p>Provides configuration to determine how to group results by document attribute value, and how to display them (collapsed or expanded) under a designated primary document for each group.</p>
pub fn collapse_configuration(mut self, input: crate::types::CollapseConfiguration) -> Self {
self.inner = self.inner.collapse_configuration(input);
self
}
/// <p>Provides configuration to determine how to group results by document attribute value, and how to display them (collapsed or expanded) under a designated primary document for each group.</p>
pub fn set_collapse_configuration(mut self, input: ::std::option::Option<crate::types::CollapseConfiguration>) -> Self {
self.inner = self.inner.set_collapse_configuration(input);
self
}
/// <p>Provides configuration to determine how to group results by document attribute value, and how to display them (collapsed or expanded) under a designated primary document for each group.</p>
pub fn get_collapse_configuration(&self) -> &::std::option::Option<crate::types::CollapseConfiguration> {
self.inner.get_collapse_configuration()
}
}