From e8351e1cae9b91d5afeff21455b4c14da466d1a7 Mon Sep 17 00:00:00 2001 From: Xiang Yan Date: Thu, 1 Apr 2021 16:04:46 -0700 Subject: [PATCH] SHA e6fa7db931a3e5182e5685630971b64987719938 --- .../v2020_06/models/_search_client_enums.py | 14 ++ .../aio/operations/_documents_operations.py | 12 ++ .../v2020_06_preview/models/__init__.py | 12 ++ .../v2020_06_preview/models/_models.py | 141 +++++++++++++++- .../v2020_06_preview/models/_models_py3.py | 151 +++++++++++++++++- .../models/_search_client_enums.py | 51 ++++++ .../operations/_documents_operations.py | 12 ++ 7 files changed, 389 insertions(+), 4 deletions(-) diff --git a/sdk/search/azure-search-documents/azure/search/documents/_generated/v2020_06/models/_search_client_enums.py b/sdk/search/azure-search-documents/azure/search/documents/_generated/v2020_06/models/_search_client_enums.py index af2e35fecc1f..55dfae9b60ad 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_generated/v2020_06/models/_search_client_enums.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_generated/v2020_06/models/_search_client_enums.py @@ -27,6 +27,9 @@ def __getattr__(cls, name): class AutocompleteMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Specifies the mode for Autocomplete. The default is 'oneTerm'. Use 'twoTerms' to get shingles + and 'oneTermWithContext' to use the current context in producing autocomplete terms. + """ #: Only one term is suggested. If the query has two terms, only the last term is completed. For #: example, if the input is 'washington medic', the suggested terms could include 'medicaid', @@ -60,6 +63,9 @@ class IndexActionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DELETE = "delete" class QueryType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Specifies the syntax of the search query. The default is 'simple'. Use 'full' if your query + uses the Lucene query syntax. + """ #: Uses the simple query syntax for searches. Search text is interpreted using a simple query #: language that allows for symbols such as +, * and "". Queries are evaluated across all @@ -71,6 +77,11 @@ class QueryType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FULL = "full" class ScoringStatistics(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """A value that specifies whether we want to calculate scoring statistics (such as document + frequency) globally for more consistent scoring, or locally, for lower latency. The default is + 'local'. Use 'global' to aggregate scoring statistics globally before scoring. Using global + scoring statistics can increase latency of search queries. + """ #: The scoring statistics will be calculated locally for lower latency. LOCAL = "local" @@ -78,6 +89,9 @@ class ScoringStatistics(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): GLOBAL_ENUM = "global" class SearchMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Specifies whether any or all of the search terms must be matched in order to count the document + as a match. + """ #: Any of the search terms must be matched in order to count the document as a match. ANY = "any" diff --git a/sdk/search/azure-search-documents/azure/search/documents/_generated/v2020_06_preview/aio/operations/_documents_operations.py b/sdk/search/azure-search-documents/azure/search/documents/_generated/v2020_06_preview/aio/operations/_documents_operations.py index cb77618f7ec2..509e89d1e6ff 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_generated/v2020_06_preview/aio/operations/_documents_operations.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_generated/v2020_06_preview/aio/operations/_documents_operations.py @@ -139,6 +139,9 @@ async def search_get( _scoring_parameters = None _scoring_profile = None _search_fields = None + _query_language = None + _speller = None + _answers = None _search_mode = None _scoring_statistics = None _session_id = None @@ -161,6 +164,9 @@ async def search_get( _scoring_parameters = search_options.scoring_parameters _scoring_profile = search_options.scoring_profile _search_fields = search_options.search_fields + _query_language = search_options.query_language + _speller = search_options.speller + _answers = search_options.answers _search_mode = search_options.search_mode _scoring_statistics = search_options.scoring_statistics _session_id = search_options.session_id @@ -206,6 +212,12 @@ async def search_get( query_parameters['scoringProfile'] = self._serialize.query("scoring_profile", _scoring_profile, 'str') if _search_fields is not None: query_parameters['searchFields'] = self._serialize.query("search_fields", _search_fields, '[str]', div=',') + if _query_language is not None: + query_parameters['queryLanguage'] = self._serialize.query("query_language", _query_language, 'str') + if _speller is not None: + query_parameters['speller'] = self._serialize.query("speller", _speller, 'str') + if _answers is not None: + query_parameters['answers'] = self._serialize.query("answers", _answers, 'str') if _search_mode is not None: query_parameters['searchMode'] = self._serialize.query("search_mode", _search_mode, 'str') if _scoring_statistics is not None: diff --git a/sdk/search/azure-search-documents/azure/search/documents/_generated/v2020_06_preview/models/__init__.py b/sdk/search/azure-search-documents/azure/search/documents/_generated/v2020_06_preview/models/__init__.py index abb65d224c74..c6e8ed8dba48 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_generated/v2020_06_preview/models/__init__.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_generated/v2020_06_preview/models/__init__.py @@ -7,10 +7,12 @@ # -------------------------------------------------------------------------- try: + from ._models_py3 import AnswerResult from ._models_py3 import AutocompleteItem from ._models_py3 import AutocompleteOptions from ._models_py3 import AutocompleteRequest from ._models_py3 import AutocompleteResult + from ._models_py3 import CaptionResult from ._models_py3 import FacetResult from ._models_py3 import IndexAction from ._models_py3 import IndexBatch @@ -27,10 +29,12 @@ from ._models_py3 import SuggestRequest from ._models_py3 import SuggestResult except (SyntaxError, ImportError): + from ._models import AnswerResult # type: ignore from ._models import AutocompleteItem # type: ignore from ._models import AutocompleteOptions # type: ignore from ._models import AutocompleteRequest # type: ignore from ._models import AutocompleteResult # type: ignore + from ._models import CaptionResult # type: ignore from ._models import FacetResult # type: ignore from ._models import IndexAction # type: ignore from ._models import IndexBatch # type: ignore @@ -48,18 +52,23 @@ from ._models import SuggestResult # type: ignore from ._search_client_enums import ( + Answers, AutocompleteMode, IndexActionType, + QueryLanguage, QueryType, ScoringStatistics, SearchMode, + Speller, ) __all__ = [ + 'AnswerResult', 'AutocompleteItem', 'AutocompleteOptions', 'AutocompleteRequest', 'AutocompleteResult', + 'CaptionResult', 'FacetResult', 'IndexAction', 'IndexBatch', @@ -75,9 +84,12 @@ 'SuggestOptions', 'SuggestRequest', 'SuggestResult', + 'Answers', 'AutocompleteMode', 'IndexActionType', + 'QueryLanguage', 'QueryType', 'ScoringStatistics', 'SearchMode', + 'Speller', ] diff --git a/sdk/search/azure-search-documents/azure/search/documents/_generated/v2020_06_preview/models/_models.py b/sdk/search/azure-search-documents/azure/search/documents/_generated/v2020_06_preview/models/_models.py index 6e303903ce07..a56c183e161c 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_generated/v2020_06_preview/models/_models.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_generated/v2020_06_preview/models/_models.py @@ -10,6 +10,53 @@ import msrest.serialization +class AnswerResult(msrest.serialization.Model): + """An answer is a text passage extracted from the contents of the most relevant documents that matched the query. Answers are extracted from the top search results. Answer candidates are scored and the top answers are selected. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param additional_properties: Unmatched properties from the message are deserialized to this + collection. + :type additional_properties: dict[str, object] + :ivar score: The score value represents how relevant the answer is to the the query relative to + other answers returned for the query. + :vartype score: float + :ivar key: The key of the document the answer was extracted from. + :vartype key: str + :ivar text: The text passage extracted from the document contents as the answer. + :vartype text: str + :ivar highlights: Same text passage as in the Text property with highlighted text phrases most + relevant to the query. + :vartype highlights: str + """ + + _validation = { + 'score': {'readonly': True}, + 'key': {'readonly': True}, + 'text': {'readonly': True}, + 'highlights': {'readonly': True}, + } + + _attribute_map = { + 'additional_properties': {'key': '', 'type': '{object}'}, + 'score': {'key': 'score', 'type': 'float'}, + 'key': {'key': 'key', 'type': 'str'}, + 'text': {'key': 'text', 'type': 'str'}, + 'highlights': {'key': 'highlights', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(AnswerResult, self).__init__(**kwargs) + self.additional_properties = kwargs.get('additional_properties', None) + self.score = None + self.key = None + self.text = None + self.highlights = None + + class AutocompleteItem(msrest.serialization.Model): """The result of Autocomplete requests. @@ -215,6 +262,43 @@ def __init__( self.results = None +class CaptionResult(msrest.serialization.Model): + """Captions are the most representative passages from the document relatively to the search query. They are often used as document summary. Captions are only returned for queries of type 'semantic'.. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param additional_properties: Unmatched properties from the message are deserialized to this + collection. + :type additional_properties: dict[str, object] + :ivar text: A representative text passage extracted from the document most relevant to the + search query. + :vartype text: str + :ivar highlights: Same text passage as in the Text property with highlighted phrases most + relevant to the query. + :vartype highlights: str + """ + + _validation = { + 'text': {'readonly': True}, + 'highlights': {'readonly': True}, + } + + _attribute_map = { + 'additional_properties': {'key': '', 'type': '{object}'}, + 'text': {'key': 'text', 'type': 'str'}, + 'highlights': {'key': 'highlights', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(CaptionResult, self).__init__(**kwargs) + self.additional_properties = kwargs.get('additional_properties', None) + self.text = None + self.highlights = None + + class FacetResult(msrest.serialization.Model): """A single bucket of a facet query result. Reports the number of documents with a field value falling within a particular range or having a particular value or interval. @@ -408,6 +492,9 @@ class SearchDocumentsResult(msrest.serialization.Model): :ivar facets: The facet query results for the search operation, organized as a collection of buckets for each faceted field; null if the query did not include any facet expressions. :vartype facets: dict[str, list[~azure.search.documents.v2020_06_preview.models.FacetResult]] + :ivar answers: The answers query results for the search operation; null if the answers query + parameter was not specified or set to 'none'. + :vartype answers: dict[str, list[~azure.search.documents.v2020_06_preview.models.AnswerResult]] :ivar next_page_parameters: Continuation JSON payload returned when Azure Cognitive Search can't return all the requested results in a single Search response. You can use this JSON along with @odata.nextLink to formulate another POST Search request to get the next part of the @@ -426,6 +513,7 @@ class SearchDocumentsResult(msrest.serialization.Model): 'count': {'readonly': True}, 'coverage': {'readonly': True}, 'facets': {'readonly': True}, + 'answers': {'readonly': True}, 'next_page_parameters': {'readonly': True}, 'results': {'required': True, 'readonly': True}, 'next_link': {'readonly': True}, @@ -435,6 +523,7 @@ class SearchDocumentsResult(msrest.serialization.Model): 'count': {'key': '@odata\\.count', 'type': 'long'}, 'coverage': {'key': '@search\\.coverage', 'type': 'float'}, 'facets': {'key': '@search\\.facets', 'type': '{[FacetResult]}'}, + 'answers': {'key': '@search\\.answers', 'type': '{[AnswerResult]}'}, 'next_page_parameters': {'key': '@search\\.nextPageParameters', 'type': 'SearchRequest'}, 'results': {'key': 'value', 'type': '[SearchResult]'}, 'next_link': {'key': '@odata\\.nextLink', 'type': 'str'}, @@ -448,6 +537,7 @@ def __init__( self.count = None self.coverage = None self.facets = None + self.answers = None self.next_page_parameters = None self.results = None self.next_link = None @@ -526,7 +616,7 @@ class SearchOptions(msrest.serialization.Model): :type order_by: list[str] :param query_type: A value that specifies the syntax of the search query. The default is 'simple'. Use 'full' if your query uses the Lucene query syntax. Possible values include: - "simple", "full". + "simple", "full", "semantic". :type query_type: str or ~azure.search.documents.v2020_06_preview.models.QueryType :param scoring_parameters: The list of parameter values to be used in scoring functions (for example, referencePointParameter) using the format name-values. For example, if the scoring @@ -540,6 +630,17 @@ class SearchOptions(msrest.serialization.Model): using fielded search (fieldName:searchExpression) in a full Lucene query, the field names of each fielded search expression take precedence over any field names listed in this parameter. :type search_fields: list[str] + :param query_language: The language of the query. Possible values include: "none", "en-us". + :type query_language: str or ~azure.search.documents.v2020_06_preview.models.QueryLanguage + :param speller: Improve search recall by spell-correcting individual search query terms. + Possible values include: "none", "lexicon". + :type speller: str or ~azure.search.documents.v2020_06_preview.models.Speller + :param answers: This parameter is only valid if the query type is 'semantic'. If set, the query + returns answers extracted from key passages in the highest ranked documents. The number of + answers returned can be configured by appending the pipe character '|' followed by the + 'count-:code:``' option after the answers parameter value, such as + 'extractive|count-3'. Default count is 1. Possible values include: "none", "extractive". + :type answers: str or ~azure.search.documents.v2020_06_preview.models.Answers :param search_mode: A value that specifies whether any or all of the search terms must be matched in order to count the document as a match. Possible values include: "any", "all". :type search_mode: str or ~azure.search.documents.v2020_06_preview.models.SearchMode @@ -582,6 +683,9 @@ class SearchOptions(msrest.serialization.Model): 'scoring_parameters': {'key': 'ScoringParameters', 'type': '[str]'}, 'scoring_profile': {'key': 'scoringProfile', 'type': 'str'}, 'search_fields': {'key': 'searchFields', 'type': '[str]'}, + 'query_language': {'key': 'queryLanguage', 'type': 'str'}, + 'speller': {'key': 'speller', 'type': 'str'}, + 'answers': {'key': 'answers', 'type': 'str'}, 'search_mode': {'key': 'searchMode', 'type': 'str'}, 'scoring_statistics': {'key': 'scoringStatistics', 'type': 'str'}, 'session_id': {'key': 'sessionId', 'type': 'str'}, @@ -607,6 +711,9 @@ def __init__( self.scoring_parameters = kwargs.get('scoring_parameters', None) self.scoring_profile = kwargs.get('scoring_profile', None) self.search_fields = kwargs.get('search_fields', None) + self.query_language = kwargs.get('query_language', None) + self.speller = kwargs.get('speller', None) + self.answers = kwargs.get('answers', None) self.search_mode = kwargs.get('search_mode', None) self.scoring_statistics = kwargs.get('scoring_statistics', None) self.session_id = kwargs.get('session_id', None) @@ -651,7 +758,7 @@ class SearchRequest(msrest.serialization.Model): :type order_by: str :param query_type: A value that specifies the syntax of the search query. The default is 'simple'. Use 'full' if your query uses the Lucene query syntax. Possible values include: - "simple", "full". + "simple", "full", "semantic". :type query_type: str or ~azure.search.documents.v2020_06_preview.models.QueryType :param scoring_statistics: A value that specifies whether we want to calculate scoring statistics (such as document frequency) globally for more consistent scoring, or locally, for @@ -686,6 +793,15 @@ class SearchRequest(msrest.serialization.Model): :param search_mode: A value that specifies whether any or all of the search terms must be matched in order to count the document as a match. Possible values include: "any", "all". :type search_mode: str or ~azure.search.documents.v2020_06_preview.models.SearchMode + :param query_language: A value that specifies the language of the search query. Possible values + include: "none", "en-us". + :type query_language: str or ~azure.search.documents.v2020_06_preview.models.QueryLanguage + :param speller: A value that specified the type of the speller to use to spell-correct + individual search query terms. Possible values include: "none", "lexicon". + :type speller: str or ~azure.search.documents.v2020_06_preview.models.Speller + :param answers: A value that specifies whether answers should be returned as part of the search + response. Possible values include: "none", "extractive". + :type answers: str or ~azure.search.documents.v2020_06_preview.models.Answers :param select: The comma-separated list of fields to retrieve. If unspecified, all fields marked as retrievable in the schema are included. :type select: str @@ -717,6 +833,9 @@ class SearchRequest(msrest.serialization.Model): 'search_text': {'key': 'search', 'type': 'str'}, 'search_fields': {'key': 'searchFields', 'type': 'str'}, 'search_mode': {'key': 'searchMode', 'type': 'str'}, + 'query_language': {'key': 'queryLanguage', 'type': 'str'}, + 'speller': {'key': 'speller', 'type': 'str'}, + 'answers': {'key': 'answers', 'type': 'str'}, 'select': {'key': 'select', 'type': 'str'}, 'skip': {'key': 'skip', 'type': 'int'}, 'top': {'key': 'top', 'type': 'int'}, @@ -743,6 +862,9 @@ def __init__( self.search_text = kwargs.get('search_text', None) self.search_fields = kwargs.get('search_fields', None) self.search_mode = kwargs.get('search_mode', None) + self.query_language = kwargs.get('query_language', None) + self.speller = kwargs.get('speller', None) + self.answers = kwargs.get('answers', None) self.select = kwargs.get('select', None) self.skip = kwargs.get('skip', None) self.top = kwargs.get('top', None) @@ -761,20 +883,33 @@ class SearchResult(msrest.serialization.Model): :ivar score: Required. The relevance score of the document compared to other documents returned by the query. :vartype score: float + :ivar reranker_score: The relevance score computed by the semantic ranker for the top search + results. Search results are sorted by the RerankerScore first and then by the Score. + RerankerScore is only returned for queries of type 'semantic'. + :vartype reranker_score: float :ivar highlights: Text fragments from the document that indicate the matching search terms, organized by each applicable field; null if hit highlighting was not enabled for the query. :vartype highlights: dict[str, list[str]] + :ivar captions: Captions are the most representative passages from the document relatively to + the search query. They are often used as document summary. Captions are only returned for + queries of type 'semantic'. + :vartype captions: dict[str, + list[~azure.search.documents.v2020_06_preview.models.CaptionResult]] """ _validation = { 'score': {'required': True, 'readonly': True}, + 'reranker_score': {'readonly': True}, 'highlights': {'readonly': True}, + 'captions': {'readonly': True}, } _attribute_map = { 'additional_properties': {'key': '', 'type': '{object}'}, 'score': {'key': '@search\\.score', 'type': 'float'}, + 'reranker_score': {'key': '@search\\.rerankerScore', 'type': 'float'}, 'highlights': {'key': '@search\\.highlights', 'type': '{[str]}'}, + 'captions': {'key': '@search\\.captions', 'type': '{[CaptionResult]}'}, } def __init__( @@ -784,7 +919,9 @@ def __init__( super(SearchResult, self).__init__(**kwargs) self.additional_properties = kwargs.get('additional_properties', None) self.score = None + self.reranker_score = None self.highlights = None + self.captions = None class SuggestDocumentsResult(msrest.serialization.Model): diff --git a/sdk/search/azure-search-documents/azure/search/documents/_generated/v2020_06_preview/models/_models_py3.py b/sdk/search/azure-search-documents/azure/search/documents/_generated/v2020_06_preview/models/_models_py3.py index c0f6994d29f1..484bcb3127b3 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_generated/v2020_06_preview/models/_models_py3.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_generated/v2020_06_preview/models/_models_py3.py @@ -14,6 +14,55 @@ from ._search_client_enums import * +class AnswerResult(msrest.serialization.Model): + """An answer is a text passage extracted from the contents of the most relevant documents that matched the query. Answers are extracted from the top search results. Answer candidates are scored and the top answers are selected. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param additional_properties: Unmatched properties from the message are deserialized to this + collection. + :type additional_properties: dict[str, object] + :ivar score: The score value represents how relevant the answer is to the the query relative to + other answers returned for the query. + :vartype score: float + :ivar key: The key of the document the answer was extracted from. + :vartype key: str + :ivar text: The text passage extracted from the document contents as the answer. + :vartype text: str + :ivar highlights: Same text passage as in the Text property with highlighted text phrases most + relevant to the query. + :vartype highlights: str + """ + + _validation = { + 'score': {'readonly': True}, + 'key': {'readonly': True}, + 'text': {'readonly': True}, + 'highlights': {'readonly': True}, + } + + _attribute_map = { + 'additional_properties': {'key': '', 'type': '{object}'}, + 'score': {'key': 'score', 'type': 'float'}, + 'key': {'key': 'key', 'type': 'str'}, + 'text': {'key': 'text', 'type': 'str'}, + 'highlights': {'key': 'highlights', 'type': 'str'}, + } + + def __init__( + self, + *, + additional_properties: Optional[Dict[str, object]] = None, + **kwargs + ): + super(AnswerResult, self).__init__(**kwargs) + self.additional_properties = additional_properties + self.score = None + self.key = None + self.text = None + self.highlights = None + + class AutocompleteItem(msrest.serialization.Model): """The result of Autocomplete requests. @@ -239,6 +288,45 @@ def __init__( self.results = None +class CaptionResult(msrest.serialization.Model): + """Captions are the most representative passages from the document relatively to the search query. They are often used as document summary. Captions are only returned for queries of type 'semantic'.. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param additional_properties: Unmatched properties from the message are deserialized to this + collection. + :type additional_properties: dict[str, object] + :ivar text: A representative text passage extracted from the document most relevant to the + search query. + :vartype text: str + :ivar highlights: Same text passage as in the Text property with highlighted phrases most + relevant to the query. + :vartype highlights: str + """ + + _validation = { + 'text': {'readonly': True}, + 'highlights': {'readonly': True}, + } + + _attribute_map = { + 'additional_properties': {'key': '', 'type': '{object}'}, + 'text': {'key': 'text', 'type': 'str'}, + 'highlights': {'key': 'highlights', 'type': 'str'}, + } + + def __init__( + self, + *, + additional_properties: Optional[Dict[str, object]] = None, + **kwargs + ): + super(CaptionResult, self).__init__(**kwargs) + self.additional_properties = additional_properties + self.text = None + self.highlights = None + + class FacetResult(msrest.serialization.Model): """A single bucket of a facet query result. Reports the number of documents with a field value falling within a particular range or having a particular value or interval. @@ -441,6 +529,9 @@ class SearchDocumentsResult(msrest.serialization.Model): :ivar facets: The facet query results for the search operation, organized as a collection of buckets for each faceted field; null if the query did not include any facet expressions. :vartype facets: dict[str, list[~azure.search.documents.v2020_06_preview.models.FacetResult]] + :ivar answers: The answers query results for the search operation; null if the answers query + parameter was not specified or set to 'none'. + :vartype answers: dict[str, list[~azure.search.documents.v2020_06_preview.models.AnswerResult]] :ivar next_page_parameters: Continuation JSON payload returned when Azure Cognitive Search can't return all the requested results in a single Search response. You can use this JSON along with @odata.nextLink to formulate another POST Search request to get the next part of the @@ -459,6 +550,7 @@ class SearchDocumentsResult(msrest.serialization.Model): 'count': {'readonly': True}, 'coverage': {'readonly': True}, 'facets': {'readonly': True}, + 'answers': {'readonly': True}, 'next_page_parameters': {'readonly': True}, 'results': {'required': True, 'readonly': True}, 'next_link': {'readonly': True}, @@ -468,6 +560,7 @@ class SearchDocumentsResult(msrest.serialization.Model): 'count': {'key': '@odata\\.count', 'type': 'long'}, 'coverage': {'key': '@search\\.coverage', 'type': 'float'}, 'facets': {'key': '@search\\.facets', 'type': '{[FacetResult]}'}, + 'answers': {'key': '@search\\.answers', 'type': '{[AnswerResult]}'}, 'next_page_parameters': {'key': '@search\\.nextPageParameters', 'type': 'SearchRequest'}, 'results': {'key': 'value', 'type': '[SearchResult]'}, 'next_link': {'key': '@odata\\.nextLink', 'type': 'str'}, @@ -481,6 +574,7 @@ def __init__( self.count = None self.coverage = None self.facets = None + self.answers = None self.next_page_parameters = None self.results = None self.next_link = None @@ -559,7 +653,7 @@ class SearchOptions(msrest.serialization.Model): :type order_by: list[str] :param query_type: A value that specifies the syntax of the search query. The default is 'simple'. Use 'full' if your query uses the Lucene query syntax. Possible values include: - "simple", "full". + "simple", "full", "semantic". :type query_type: str or ~azure.search.documents.v2020_06_preview.models.QueryType :param scoring_parameters: The list of parameter values to be used in scoring functions (for example, referencePointParameter) using the format name-values. For example, if the scoring @@ -573,6 +667,17 @@ class SearchOptions(msrest.serialization.Model): using fielded search (fieldName:searchExpression) in a full Lucene query, the field names of each fielded search expression take precedence over any field names listed in this parameter. :type search_fields: list[str] + :param query_language: The language of the query. Possible values include: "none", "en-us". + :type query_language: str or ~azure.search.documents.v2020_06_preview.models.QueryLanguage + :param speller: Improve search recall by spell-correcting individual search query terms. + Possible values include: "none", "lexicon". + :type speller: str or ~azure.search.documents.v2020_06_preview.models.Speller + :param answers: This parameter is only valid if the query type is 'semantic'. If set, the query + returns answers extracted from key passages in the highest ranked documents. The number of + answers returned can be configured by appending the pipe character '|' followed by the + 'count-:code:``' option after the answers parameter value, such as + 'extractive|count-3'. Default count is 1. Possible values include: "none", "extractive". + :type answers: str or ~azure.search.documents.v2020_06_preview.models.Answers :param search_mode: A value that specifies whether any or all of the search terms must be matched in order to count the document as a match. Possible values include: "any", "all". :type search_mode: str or ~azure.search.documents.v2020_06_preview.models.SearchMode @@ -615,6 +720,9 @@ class SearchOptions(msrest.serialization.Model): 'scoring_parameters': {'key': 'ScoringParameters', 'type': '[str]'}, 'scoring_profile': {'key': 'scoringProfile', 'type': 'str'}, 'search_fields': {'key': 'searchFields', 'type': '[str]'}, + 'query_language': {'key': 'queryLanguage', 'type': 'str'}, + 'speller': {'key': 'speller', 'type': 'str'}, + 'answers': {'key': 'answers', 'type': 'str'}, 'search_mode': {'key': 'searchMode', 'type': 'str'}, 'scoring_statistics': {'key': 'scoringStatistics', 'type': 'str'}, 'session_id': {'key': 'sessionId', 'type': 'str'}, @@ -638,6 +746,9 @@ def __init__( scoring_parameters: Optional[List[str]] = None, scoring_profile: Optional[str] = None, search_fields: Optional[List[str]] = None, + query_language: Optional[Union[str, "QueryLanguage"]] = None, + speller: Optional[Union[str, "Speller"]] = None, + answers: Optional[Union[str, "Answers"]] = None, search_mode: Optional[Union[str, "SearchMode"]] = None, scoring_statistics: Optional[Union[str, "ScoringStatistics"]] = None, session_id: Optional[str] = None, @@ -659,6 +770,9 @@ def __init__( self.scoring_parameters = scoring_parameters self.scoring_profile = scoring_profile self.search_fields = search_fields + self.query_language = query_language + self.speller = speller + self.answers = answers self.search_mode = search_mode self.scoring_statistics = scoring_statistics self.session_id = session_id @@ -703,7 +817,7 @@ class SearchRequest(msrest.serialization.Model): :type order_by: str :param query_type: A value that specifies the syntax of the search query. The default is 'simple'. Use 'full' if your query uses the Lucene query syntax. Possible values include: - "simple", "full". + "simple", "full", "semantic". :type query_type: str or ~azure.search.documents.v2020_06_preview.models.QueryType :param scoring_statistics: A value that specifies whether we want to calculate scoring statistics (such as document frequency) globally for more consistent scoring, or locally, for @@ -738,6 +852,15 @@ class SearchRequest(msrest.serialization.Model): :param search_mode: A value that specifies whether any or all of the search terms must be matched in order to count the document as a match. Possible values include: "any", "all". :type search_mode: str or ~azure.search.documents.v2020_06_preview.models.SearchMode + :param query_language: A value that specifies the language of the search query. Possible values + include: "none", "en-us". + :type query_language: str or ~azure.search.documents.v2020_06_preview.models.QueryLanguage + :param speller: A value that specified the type of the speller to use to spell-correct + individual search query terms. Possible values include: "none", "lexicon". + :type speller: str or ~azure.search.documents.v2020_06_preview.models.Speller + :param answers: A value that specifies whether answers should be returned as part of the search + response. Possible values include: "none", "extractive". + :type answers: str or ~azure.search.documents.v2020_06_preview.models.Answers :param select: The comma-separated list of fields to retrieve. If unspecified, all fields marked as retrievable in the schema are included. :type select: str @@ -769,6 +892,9 @@ class SearchRequest(msrest.serialization.Model): 'search_text': {'key': 'search', 'type': 'str'}, 'search_fields': {'key': 'searchFields', 'type': 'str'}, 'search_mode': {'key': 'searchMode', 'type': 'str'}, + 'query_language': {'key': 'queryLanguage', 'type': 'str'}, + 'speller': {'key': 'speller', 'type': 'str'}, + 'answers': {'key': 'answers', 'type': 'str'}, 'select': {'key': 'select', 'type': 'str'}, 'skip': {'key': 'skip', 'type': 'int'}, 'top': {'key': 'top', 'type': 'int'}, @@ -793,6 +919,9 @@ def __init__( search_text: Optional[str] = None, search_fields: Optional[str] = None, search_mode: Optional[Union[str, "SearchMode"]] = None, + query_language: Optional[Union[str, "QueryLanguage"]] = None, + speller: Optional[Union[str, "Speller"]] = None, + answers: Optional[Union[str, "Answers"]] = None, select: Optional[str] = None, skip: Optional[int] = None, top: Optional[int] = None, @@ -815,6 +944,9 @@ def __init__( self.search_text = search_text self.search_fields = search_fields self.search_mode = search_mode + self.query_language = query_language + self.speller = speller + self.answers = answers self.select = select self.skip = skip self.top = top @@ -833,20 +965,33 @@ class SearchResult(msrest.serialization.Model): :ivar score: Required. The relevance score of the document compared to other documents returned by the query. :vartype score: float + :ivar reranker_score: The relevance score computed by the semantic ranker for the top search + results. Search results are sorted by the RerankerScore first and then by the Score. + RerankerScore is only returned for queries of type 'semantic'. + :vartype reranker_score: float :ivar highlights: Text fragments from the document that indicate the matching search terms, organized by each applicable field; null if hit highlighting was not enabled for the query. :vartype highlights: dict[str, list[str]] + :ivar captions: Captions are the most representative passages from the document relatively to + the search query. They are often used as document summary. Captions are only returned for + queries of type 'semantic'. + :vartype captions: dict[str, + list[~azure.search.documents.v2020_06_preview.models.CaptionResult]] """ _validation = { 'score': {'required': True, 'readonly': True}, + 'reranker_score': {'readonly': True}, 'highlights': {'readonly': True}, + 'captions': {'readonly': True}, } _attribute_map = { 'additional_properties': {'key': '', 'type': '{object}'}, 'score': {'key': '@search\\.score', 'type': 'float'}, + 'reranker_score': {'key': '@search\\.rerankerScore', 'type': 'float'}, 'highlights': {'key': '@search\\.highlights', 'type': '{[str]}'}, + 'captions': {'key': '@search\\.captions', 'type': '{[CaptionResult]}'}, } def __init__( @@ -858,7 +1003,9 @@ def __init__( super(SearchResult, self).__init__(**kwargs) self.additional_properties = additional_properties self.score = None + self.reranker_score = None self.highlights = None + self.captions = None class SuggestDocumentsResult(msrest.serialization.Model): diff --git a/sdk/search/azure-search-documents/azure/search/documents/_generated/v2020_06_preview/models/_search_client_enums.py b/sdk/search/azure-search-documents/azure/search/documents/_generated/v2020_06_preview/models/_search_client_enums.py index af2e35fecc1f..1f278e8c478c 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_generated/v2020_06_preview/models/_search_client_enums.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_generated/v2020_06_preview/models/_search_client_enums.py @@ -26,7 +26,24 @@ def __getattr__(cls, name): raise AttributeError(name) +class Answers(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """This parameter is only valid if the query type is 'semantic'. If set, the query returns answers + extracted from key passages in the highest ranked documents. The number of answers returned can + be configured by appending the pipe character '|' followed by the 'count-:code:``' option after the answers parameter value, such as 'extractive|count-3'. Default + count is 1. + """ + + #: Do not return answers for the query. + NONE = "none" + #: Extracts answer candidates from the contents of the documents returned in response to a query + #: expressed as a question in natural language. + EXTRACTIVE = "extractive" + class AutocompleteMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Specifies the mode for Autocomplete. The default is 'oneTerm'. Use 'twoTerms' to get shingles + and 'oneTermWithContext' to use the current context in producing autocomplete terms. + """ #: Only one term is suggested. If the query has two terms, only the last term is completed. For #: example, if the input is 'washington medic', the suggested terms could include 'medicaid', @@ -59,7 +76,19 @@ class IndexActionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: document, use merge instead and set the field explicitly to null. DELETE = "delete" +class QueryLanguage(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The language of the query. + """ + + #: Query language not specified. + NONE = "none" + #: English. + EN_US = "en-us" + class QueryType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Specifies the syntax of the search query. The default is 'simple'. Use 'full' if your query + uses the Lucene query syntax and 'semantic' if query syntax is not needed. + """ #: Uses the simple query syntax for searches. Search text is interpreted using a simple query #: language that allows for symbols such as +, * and "". Queries are evaluated across all @@ -69,8 +98,17 @@ class QueryType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: query language which allows field-specific and weighted searches, as well as other advanced #: features. FULL = "full" + #: Best suited for queries expressed in natural language as opposed to keywords. Improves + #: precision of search results by re-ranking the top search results using a ranking model trained + #: on the Web corpus. + SEMANTIC = "semantic" class ScoringStatistics(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """A value that specifies whether we want to calculate scoring statistics (such as document + frequency) globally for more consistent scoring, or locally, for lower latency. The default is + 'local'. Use 'global' to aggregate scoring statistics globally before scoring. Using global + scoring statistics can increase latency of search queries. + """ #: The scoring statistics will be calculated locally for lower latency. LOCAL = "local" @@ -78,8 +116,21 @@ class ScoringStatistics(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): GLOBAL_ENUM = "global" class SearchMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Specifies whether any or all of the search terms must be matched in order to count the document + as a match. + """ #: Any of the search terms must be matched in order to count the document as a match. ANY = "any" #: All of the search terms must be matched in order to count the document as a match. ALL = "all" + +class Speller(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Improve search recall by spell-correcting individual search query terms. + """ + + #: Speller not enabled. + NONE = "none" + #: Speller corrects individual query terms using a static lexicon for the language specified by + #: the queryLanguage parameter. + LEXICON = "lexicon" diff --git a/sdk/search/azure-search-documents/azure/search/documents/_generated/v2020_06_preview/operations/_documents_operations.py b/sdk/search/azure-search-documents/azure/search/documents/_generated/v2020_06_preview/operations/_documents_operations.py index d1f737f530bd..19934c6a83f3 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_generated/v2020_06_preview/operations/_documents_operations.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_generated/v2020_06_preview/operations/_documents_operations.py @@ -145,6 +145,9 @@ def search_get( _scoring_parameters = None _scoring_profile = None _search_fields = None + _query_language = None + _speller = None + _answers = None _search_mode = None _scoring_statistics = None _session_id = None @@ -167,6 +170,9 @@ def search_get( _scoring_parameters = search_options.scoring_parameters _scoring_profile = search_options.scoring_profile _search_fields = search_options.search_fields + _query_language = search_options.query_language + _speller = search_options.speller + _answers = search_options.answers _search_mode = search_options.search_mode _scoring_statistics = search_options.scoring_statistics _session_id = search_options.session_id @@ -212,6 +218,12 @@ def search_get( query_parameters['scoringProfile'] = self._serialize.query("scoring_profile", _scoring_profile, 'str') if _search_fields is not None: query_parameters['searchFields'] = self._serialize.query("search_fields", _search_fields, '[str]', div=',') + if _query_language is not None: + query_parameters['queryLanguage'] = self._serialize.query("query_language", _query_language, 'str') + if _speller is not None: + query_parameters['speller'] = self._serialize.query("speller", _speller, 'str') + if _answers is not None: + query_parameters['answers'] = self._serialize.query("answers", _answers, 'str') if _search_mode is not None: query_parameters['searchMode'] = self._serialize.query("search_mode", _search_mode, 'str') if _scoring_statistics is not None: