@@ -4843,6 +4843,12 @@ class SearchResult():
48434843 :attr SearchResultHighlight highlight: (optional) An object containing segments
48444844 of text from search results with query-matching text highlighted using HTML
48454845 `<em>` tags.
4846+ :attr List[SearchResultAnswer] answers: (optional) An array specifying segments
4847+ of text within the result that were identified as direct answers to the search
4848+ query. Currently, only the single answer with the highest confidence (if any) is
4849+ returned.
4850+ **Note:** This property uses the answer finding beta feature, and is available
4851+ only if the search skill is connected to a Discovery v2 service instance.
48464852 """
48474853
48484854 def __init__ (self ,
@@ -4852,7 +4858,8 @@ def __init__(self,
48524858 body : str = None ,
48534859 title : str = None ,
48544860 url : str = None ,
4855- highlight : 'SearchResultHighlight' = None ) -> None :
4861+ highlight : 'SearchResultHighlight' = None ,
4862+ answers : List ['SearchResultAnswer' ] = None ) -> None :
48564863 """
48574864 Initialize a SearchResult object.
48584865
@@ -4873,13 +4880,21 @@ def __init__(self,
48734880 :param SearchResultHighlight highlight: (optional) An object containing
48744881 segments of text from search results with query-matching text highlighted
48754882 using HTML `<em>` tags.
4883+ :param List[SearchResultAnswer] answers: (optional) An array specifying
4884+ segments of text within the result that were identified as direct answers
4885+ to the search query. Currently, only the single answer with the highest
4886+ confidence (if any) is returned.
4887+ **Note:** This property uses the answer finding beta feature, and is
4888+ available only if the search skill is connected to a Discovery v2 service
4889+ instance.
48764890 """
48774891 self .id = id
48784892 self .result_metadata = result_metadata
48794893 self .body = body
48804894 self .title = title
48814895 self .url = url
48824896 self .highlight = highlight
4897+ self .answers = answers
48834898
48844899 @classmethod
48854900 def from_dict (cls , _dict : Dict ) -> 'SearchResult' :
@@ -4906,6 +4921,10 @@ def from_dict(cls, _dict: Dict) -> 'SearchResult':
49064921 if 'highlight' in _dict :
49074922 args ['highlight' ] = SearchResultHighlight .from_dict (
49084923 _dict .get ('highlight' ))
4924+ if 'answers' in _dict :
4925+ args ['answers' ] = [
4926+ SearchResultAnswer .from_dict (x ) for x in _dict .get ('answers' )
4927+ ]
49094928 return cls (** args )
49104929
49114930 @classmethod
@@ -4929,6 +4948,8 @@ def to_dict(self) -> Dict:
49294948 _dict ['url' ] = self .url
49304949 if hasattr (self , 'highlight' ) and self .highlight is not None :
49314950 _dict ['highlight' ] = self .highlight .to_dict ()
4951+ if hasattr (self , 'answers' ) and self .answers is not None :
4952+ _dict ['answers' ] = [x .to_dict () for x in self .answers ]
49324953 return _dict
49334954
49344955 def _to_dict (self ):
@@ -4950,6 +4971,78 @@ def __ne__(self, other: 'SearchResult') -> bool:
49504971 return not self == other
49514972
49524973
4974+ class SearchResultAnswer ():
4975+ """
4976+ An object specifing a segment of text that was identified as a direct answer to the
4977+ search query.
4978+
4979+ :attr str text: The text of the answer.
4980+ :attr float confidence: The confidence score for the answer, as returned by the
4981+ Discovery service.
4982+ """
4983+
4984+ def __init__ (self , text : str , confidence : float ) -> None :
4985+ """
4986+ Initialize a SearchResultAnswer object.
4987+
4988+ :param str text: The text of the answer.
4989+ :param float confidence: The confidence score for the answer, as returned
4990+ by the Discovery service.
4991+ """
4992+ self .text = text
4993+ self .confidence = confidence
4994+
4995+ @classmethod
4996+ def from_dict (cls , _dict : Dict ) -> 'SearchResultAnswer' :
4997+ """Initialize a SearchResultAnswer object from a json dictionary."""
4998+ args = {}
4999+ if 'text' in _dict :
5000+ args ['text' ] = _dict .get ('text' )
5001+ else :
5002+ raise ValueError (
5003+ 'Required property \' text\' not present in SearchResultAnswer JSON'
5004+ )
5005+ if 'confidence' in _dict :
5006+ args ['confidence' ] = _dict .get ('confidence' )
5007+ else :
5008+ raise ValueError (
5009+ 'Required property \' confidence\' not present in SearchResultAnswer JSON'
5010+ )
5011+ return cls (** args )
5012+
5013+ @classmethod
5014+ def _from_dict (cls , _dict ):
5015+ """Initialize a SearchResultAnswer object from a json dictionary."""
5016+ return cls .from_dict (_dict )
5017+
5018+ def to_dict (self ) -> Dict :
5019+ """Return a json dictionary representing this model."""
5020+ _dict = {}
5021+ if hasattr (self , 'text' ) and self .text is not None :
5022+ _dict ['text' ] = self .text
5023+ if hasattr (self , 'confidence' ) and self .confidence is not None :
5024+ _dict ['confidence' ] = self .confidence
5025+ return _dict
5026+
5027+ def _to_dict (self ):
5028+ """Return a json dictionary representing this model."""
5029+ return self .to_dict ()
5030+
5031+ def __str__ (self ) -> str :
5032+ """Return a `str` version of this SearchResultAnswer object."""
5033+ return json .dumps (self .to_dict (), indent = 2 )
5034+
5035+ def __eq__ (self , other : 'SearchResultAnswer' ) -> bool :
5036+ """Return `true` when self and other are equal, false otherwise."""
5037+ if not isinstance (other , self .__class__ ):
5038+ return False
5039+ return self .__dict__ == other .__dict__
5040+
5041+ def __ne__ (self , other : 'SearchResultAnswer' ) -> bool :
5042+ """Return `true` when self and other are not equal, false otherwise."""
5043+ return not self == other
5044+
5045+
49535046class SearchResultHighlight ():
49545047 """
49555048 An object containing segments of text from search results with query-matching text
0 commit comments