aws_sdk_kendra/types/
_expanded_result_item.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// <p>A single expanded result in a collapsed group of search results.</p>
4/// <p>An expanded result item contains information about an expanded result document within a collapsed group of search results. This includes the original location of the document, a list of attributes assigned to the document, and relevant text from the document that satisfies the query.</p>
5#[non_exhaustive]
6#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
7pub struct ExpandedResultItem {
8    /// <p>The identifier for the expanded result.</p>
9    pub id: ::std::option::Option<::std::string::String>,
10    /// <p>The idenitifier of the document.</p>
11    pub document_id: ::std::option::Option<::std::string::String>,
12    /// <p>Provides text and information about where to highlight the text.</p>
13    pub document_title: ::std::option::Option<crate::types::TextWithHighlights>,
14    /// <p>Provides text and information about where to highlight the text.</p>
15    pub document_excerpt: ::std::option::Option<crate::types::TextWithHighlights>,
16    /// <p>The URI of the original location of the document.</p>
17    pub document_uri: ::std::option::Option<::std::string::String>,
18    /// <p>An array of document attributes assigned to a document in the search results. For example, the document author ("_author") or the source URI ("_source_uri") of the document.</p>
19    pub document_attributes: ::std::option::Option<::std::vec::Vec<crate::types::DocumentAttribute>>,
20}
21impl ExpandedResultItem {
22    /// <p>The identifier for the expanded result.</p>
23    pub fn id(&self) -> ::std::option::Option<&str> {
24        self.id.as_deref()
25    }
26    /// <p>The idenitifier of the document.</p>
27    pub fn document_id(&self) -> ::std::option::Option<&str> {
28        self.document_id.as_deref()
29    }
30    /// <p>Provides text and information about where to highlight the text.</p>
31    pub fn document_title(&self) -> ::std::option::Option<&crate::types::TextWithHighlights> {
32        self.document_title.as_ref()
33    }
34    /// <p>Provides text and information about where to highlight the text.</p>
35    pub fn document_excerpt(&self) -> ::std::option::Option<&crate::types::TextWithHighlights> {
36        self.document_excerpt.as_ref()
37    }
38    /// <p>The URI of the original location of the document.</p>
39    pub fn document_uri(&self) -> ::std::option::Option<&str> {
40        self.document_uri.as_deref()
41    }
42    /// <p>An array of document attributes assigned to a document in the search results. For example, the document author ("_author") or the source URI ("_source_uri") of the document.</p>
43    ///
44    /// If no value was sent for this field, a default will be set. If you want to determine if no value was sent, use `.document_attributes.is_none()`.
45    pub fn document_attributes(&self) -> &[crate::types::DocumentAttribute] {
46        self.document_attributes.as_deref().unwrap_or_default()
47    }
48}
49impl ExpandedResultItem {
50    /// Creates a new builder-style object to manufacture [`ExpandedResultItem`](crate::types::ExpandedResultItem).
51    pub fn builder() -> crate::types::builders::ExpandedResultItemBuilder {
52        crate::types::builders::ExpandedResultItemBuilder::default()
53    }
54}
55
56/// A builder for [`ExpandedResultItem`](crate::types::ExpandedResultItem).
57#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
58#[non_exhaustive]
59pub struct ExpandedResultItemBuilder {
60    pub(crate) id: ::std::option::Option<::std::string::String>,
61    pub(crate) document_id: ::std::option::Option<::std::string::String>,
62    pub(crate) document_title: ::std::option::Option<crate::types::TextWithHighlights>,
63    pub(crate) document_excerpt: ::std::option::Option<crate::types::TextWithHighlights>,
64    pub(crate) document_uri: ::std::option::Option<::std::string::String>,
65    pub(crate) document_attributes: ::std::option::Option<::std::vec::Vec<crate::types::DocumentAttribute>>,
66}
67impl ExpandedResultItemBuilder {
68    /// <p>The identifier for the expanded result.</p>
69    pub fn id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
70        self.id = ::std::option::Option::Some(input.into());
71        self
72    }
73    /// <p>The identifier for the expanded result.</p>
74    pub fn set_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
75        self.id = input;
76        self
77    }
78    /// <p>The identifier for the expanded result.</p>
79    pub fn get_id(&self) -> &::std::option::Option<::std::string::String> {
80        &self.id
81    }
82    /// <p>The idenitifier of the document.</p>
83    pub fn document_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
84        self.document_id = ::std::option::Option::Some(input.into());
85        self
86    }
87    /// <p>The idenitifier of the document.</p>
88    pub fn set_document_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
89        self.document_id = input;
90        self
91    }
92    /// <p>The idenitifier of the document.</p>
93    pub fn get_document_id(&self) -> &::std::option::Option<::std::string::String> {
94        &self.document_id
95    }
96    /// <p>Provides text and information about where to highlight the text.</p>
97    pub fn document_title(mut self, input: crate::types::TextWithHighlights) -> Self {
98        self.document_title = ::std::option::Option::Some(input);
99        self
100    }
101    /// <p>Provides text and information about where to highlight the text.</p>
102    pub fn set_document_title(mut self, input: ::std::option::Option<crate::types::TextWithHighlights>) -> Self {
103        self.document_title = input;
104        self
105    }
106    /// <p>Provides text and information about where to highlight the text.</p>
107    pub fn get_document_title(&self) -> &::std::option::Option<crate::types::TextWithHighlights> {
108        &self.document_title
109    }
110    /// <p>Provides text and information about where to highlight the text.</p>
111    pub fn document_excerpt(mut self, input: crate::types::TextWithHighlights) -> Self {
112        self.document_excerpt = ::std::option::Option::Some(input);
113        self
114    }
115    /// <p>Provides text and information about where to highlight the text.</p>
116    pub fn set_document_excerpt(mut self, input: ::std::option::Option<crate::types::TextWithHighlights>) -> Self {
117        self.document_excerpt = input;
118        self
119    }
120    /// <p>Provides text and information about where to highlight the text.</p>
121    pub fn get_document_excerpt(&self) -> &::std::option::Option<crate::types::TextWithHighlights> {
122        &self.document_excerpt
123    }
124    /// <p>The URI of the original location of the document.</p>
125    pub fn document_uri(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
126        self.document_uri = ::std::option::Option::Some(input.into());
127        self
128    }
129    /// <p>The URI of the original location of the document.</p>
130    pub fn set_document_uri(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
131        self.document_uri = input;
132        self
133    }
134    /// <p>The URI of the original location of the document.</p>
135    pub fn get_document_uri(&self) -> &::std::option::Option<::std::string::String> {
136        &self.document_uri
137    }
138    /// Appends an item to `document_attributes`.
139    ///
140    /// To override the contents of this collection use [`set_document_attributes`](Self::set_document_attributes).
141    ///
142    /// <p>An array of document attributes assigned to a document in the search results. For example, the document author ("_author") or the source URI ("_source_uri") of the document.</p>
143    pub fn document_attributes(mut self, input: crate::types::DocumentAttribute) -> Self {
144        let mut v = self.document_attributes.unwrap_or_default();
145        v.push(input);
146        self.document_attributes = ::std::option::Option::Some(v);
147        self
148    }
149    /// <p>An array of document attributes assigned to a document in the search results. For example, the document author ("_author") or the source URI ("_source_uri") of the document.</p>
150    pub fn set_document_attributes(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::DocumentAttribute>>) -> Self {
151        self.document_attributes = input;
152        self
153    }
154    /// <p>An array of document attributes assigned to a document in the search results. For example, the document author ("_author") or the source URI ("_source_uri") of the document.</p>
155    pub fn get_document_attributes(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::DocumentAttribute>> {
156        &self.document_attributes
157    }
158    /// Consumes the builder and constructs a [`ExpandedResultItem`](crate::types::ExpandedResultItem).
159    pub fn build(self) -> crate::types::ExpandedResultItem {
160        crate::types::ExpandedResultItem {
161            id: self.id,
162            document_id: self.document_id,
163            document_title: self.document_title,
164            document_excerpt: self.document_excerpt,
165            document_uri: self.document_uri,
166            document_attributes: self.document_attributes,
167        }
168    }
169}