Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove beta features from main #25795

Merged
merged 17 commits into from
Aug 31, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
class ApiVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta):
#: this is the default version
V2020_06_30 = "2020-06-30"
V2021_04_30_PREVIEW = "2021-04-30-Preview"


DEFAULT_VERSION = ApiVersion.V2021_04_30_PREVIEW
DEFAULT_VERSION = ApiVersion.V2020_06_30
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
if TYPE_CHECKING:
# pylint:disable=unused-import,ungrouped-imports
from typing import Any, Union
from ..documents.models import AnswerResult


def convert_search_result(result):
Expand Down Expand Up @@ -82,11 +81,6 @@ def get_count(self):
"""
return self._first_iterator_instance().get_count()

def get_answers(self):
# type: () -> Union[list[AnswerResult], None]
"""Return answers."""
return self._first_iterator_instance().get_answers()


# The pylint error silenced below seems spurious, as the inner wrapper does, in
# fact, become a method of the class when it is applied.
Expand Down Expand Up @@ -152,8 +146,3 @@ def get_coverage(self):
def get_count(self):
self.continuation_token = None
return self._response.count

@_ensure_response
def get_answers(self):
self.continuation_token = None
return self._response.answers
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,9 @@ def get_document(self, key, selected_fields=None, **kwargs):
return cast(dict, result)

@distributed_trace
def search(self, search_text, **kwargs): # pylint:disable=too-many-locals
def search(self, search_text, **kwargs):
# type: (str, **Any) -> SearchItemPaged[dict]
"""Search the Azure search index for documents.

:param str search_text: A full-text search query expression; Use "*" or omit this parameter to
match all documents.
:keyword bool include_total_count: A value that specifies whether to fetch the total count of
Expand Down Expand Up @@ -201,35 +200,6 @@ def search(self, search_text, **kwargs): # pylint:disable=too-many-locals
:keyword 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'.
:paramtype search_mode: str or ~azure.search.documents.models.SearchMode
:keyword query_language: The language of the search query. Possible values include: "none", "en-us",
"en-gb", "en-in", "en-ca", "en-au", "fr-fr", "fr-ca", "de-de", "es-es", "es-mx", "zh-cn",
"zh-tw", "pt-br", "pt-pt", "it-it", "ja-jp", "ko-kr", "ru-ru", "cs-cz", "nl-be", "nl-nl",
"hu-hu", "pl-pl", "sv-se", "tr-tr", "hi-in", "ar-sa", "ar-eg", "ar-ma", "ar-kw", "ar-jo",
"da-dk", "no-no", "bg-bg", "hr-hr", "hr-ba", "ms-my", "ms-bn", "sl-sl", "ta-in", "vi-vn",
"el-gr", "ro-ro", "is-is", "id-id", "th-th", "lt-lt", "uk-ua", "lv-lv", "et-ee", "ca-es",
"fi-fi", "sr-ba", "sr-me", "sr-rs", "sk-sk", "nb-no", "hy-am", "bn-in", "eu-es", "gl-es",
"gu-in", "he-il", "ga-ie", "kn-in", "ml-in", "mr-in", "fa-ae", "pa-in", "te-in", "ur-pk".
:paramtype query_language: str or ~azure.search.documents.models.QueryLanguage
:keyword query_speller: A value that specified the type of the speller to use to spell-correct
individual search query terms. Possible values include: "none", "lexicon".
:paramtype query_speller: str or ~azure.search.documents.models.QuerySpellerType
:keyword query_answer: 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.
Possible values include: "none", "extractive".
:paramtype query_answer: str or ~azure.search.documents.models.QueryAnswerType
:keyword int query_answer_count: This parameter is only valid if the query type is 'semantic' and
query answer is 'extractive'. Configures the number of answers returned. Default count is 1.
:keyword query_caption: This parameter is only valid if the query type is 'semantic'. If set, the
query returns captions extracted from key passages in the highest ranked documents.
Defaults to 'None'. Possible values include: "none", "extractive".
:paramtype query_caption: str or ~azure.search.documents.models.QueryCaptionType
:keyword bool query_caption_highlight: This parameter is only valid if the query type is 'semantic' when
query caption is set to 'extractive'. Determines whether highlighting is enabled.
Defaults to 'true'.
:keyword list[str] semantic_fields: The list of field names used for semantic search.
:keyword semantic_configuration_name: The name of the semantic configuration that will be used when
processing documents for queries of type semantic.
:paramtype semantic_configuration_name: str
:keyword list[str] select: The list of fields to retrieve. If unspecified, all fields marked as retrievable
in the schema are included.
:keyword int skip: The number of search results to skip. This value cannot be greater than 100,000.
Expand All @@ -239,40 +209,22 @@ def search(self, search_text, **kwargs): # pylint:disable=too-many-locals
$skip to implement client-side paging of search results. If results are truncated due to
server-side paging, the response will include a continuation token that can be used to issue
another Search request for the next page of results.
:keyword 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
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.
Possible values include: "local", "global".
:paramtype scoring_statistics: str or ~azure.search.documents.models.ScoringStatistics
:keyword str session_id: A value to be used to create a sticky session, which can help getting more
consistent results. As long as the same sessionId is used, a best-effort attempt will be made
to target the same replica set. Be wary that reusing the same sessionID values repeatedly can
interfere with the load balancing of the requests across replicas and adversely affect the
performance of the search service. The value used as sessionId cannot start with a '_'
character.
:rtype: SearchItemPaged[dict]

.. admonition:: Example:

.. literalinclude:: ../samples/sample_simple_query.py
:start-after: [START simple_query]
:end-before: [END simple_query]
:language: python
:dedent: 4
:caption: Search on a simple text term.

.. admonition:: Example:

.. literalinclude:: ../samples/sample_filter_query.py
:start-after: [START filter_query]
:end-before: [END filter_query]
:language: python
:dedent: 4
:caption: Filter and sort search results.

.. admonition:: Example:

.. literalinclude:: ../samples/sample_facet_query.py
:start-after: [START facet_query]
:end-before: [END facet_query]
Expand All @@ -294,29 +246,9 @@ def search(self, search_text, **kwargs): # pylint:disable=too-many-locals
search_fields = kwargs.pop("search_fields", None)
search_fields_str = ",".join(search_fields) if search_fields else None
search_mode = kwargs.pop("search_mode", None)
query_language = kwargs.pop("query_language", None)
query_speller = kwargs.pop("query_speller", None)
select = kwargs.pop("select", None)
skip = kwargs.pop("skip", None)
top = kwargs.pop("top", None)
session_id = kwargs.pop("session_id", None)
scoring_statistics = kwargs.pop("scoring_statistics", None)

query_answer = kwargs.pop("query_answer", None)
query_answer_count = kwargs.pop("query_answer_count", None)
answers = query_answer if not query_answer_count else '{}|count-{}'.format(
query_answer, query_answer_count
)

query_caption = kwargs.pop("query_caption", None)
query_caption_highlight = kwargs.pop("query_caption_highlight", None)
captions = query_caption if not query_caption_highlight else '{}|highlight-{}'.format(
query_caption, query_caption_highlight
)

semantic_fields = kwargs.pop("semantic_fields", None)
semantic_configuration = kwargs.pop("semantic_configuration_name", None)

query = SearchQuery(
search_text=search_text,
include_total_result_count=include_total_result_count,
Expand All @@ -332,17 +264,9 @@ def search(self, search_text, **kwargs): # pylint:disable=too-many-locals
scoring_profile=scoring_profile,
search_fields=search_fields_str,
search_mode=search_mode,
query_language=query_language,
speller=query_speller,
answers=answers,
captions=captions,
semantic_fields=",".join(semantic_fields) if semantic_fields else None,
semantic_configuration=semantic_configuration,
select=select if isinstance(select, six.string_types) else None,
skip=skip,
top=top,
session_id=session_id,
scoring_statistics=scoring_statistics
top=top
)
if isinstance(select, list):
query.select(select)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
# Licensed under the MIT License.
# ------------------------------------

VERSION = "11.3.0b9" # type: str
VERSION = "11.3.0" # type: str

SDK_MONIKER = "search-documents/{}".format(VERSION) # type: str
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,15 @@
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
from typing import Union, TYPE_CHECKING
from typing import Union

from azure.core.async_paging import AsyncItemPaged, AsyncPageIterator, ReturnType
from .._generated.models import SearchRequest
from .._paging import (
convert_search_result,
pack_continuation_token,
unpack_continuation_token,
)

if TYPE_CHECKING:
# pylint:disable=unused-import,ungrouped-imports
from ...documents.models import AnswerResult


class AsyncSearchItemPaged(AsyncItemPaged[ReturnType]):
def __init__(self, *args, **kwargs):
Expand Down Expand Up @@ -64,11 +59,6 @@ async def get_count(self):
"""
return await self._first_iterator_instance().get_count()

async def get_answers(self):
# type: () -> Union[list[AnswerResult], None]
"""Return answers."""
return await self._first_iterator_instance().get_answers()


# The pylint error silenced below seems spurious, as the inner wrapper does, in
# fact, become a method of the class when it is applied.
Expand Down Expand Up @@ -134,8 +124,3 @@ async def get_coverage(self):
async def get_count(self):
self.continuation_token = None
return self._response.count

@_ensure_response
async def get_answers(self):
self.continuation_token = None
return self._response.answers
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ async def get_document(self, key, selected_fields=None, **kwargs):
async def search(self, search_text, **kwargs): # pylint:disable=too-many-locals
# type: (str, **Any) -> AsyncSearchItemPaged[dict]
"""Search the Azure search index for documents.

:param str search_text: A full-text search query expression; Use "*" or omit this parameter to
match all documents.
:keyword bool include_total_count: A value that specifies whether to fetch the total count of
Expand Down Expand Up @@ -179,36 +178,6 @@ async def search(self, search_text, **kwargs): # pylint:disable=too-many-locals
:keyword 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'.
:paramtype search_mode: str or ~azure.search.documents.models.SearchMode
:keyword query_language: The language of the search query. Possible values include: "none", "en-us",
"en-gb", "en-in", "en-ca", "en-au", "fr-fr", "fr-ca", "de-de", "es-es", "es-mx", "zh-cn",
"zh-tw", "pt-br", "pt-pt", "it-it", "ja-jp", "ko-kr", "ru-ru", "cs-cz", "nl-be", "nl-nl",
"hu-hu", "pl-pl", "sv-se", "tr-tr", "hi-in", "ar-sa", "ar-eg", "ar-ma", "ar-kw", "ar-jo",
"da-dk", "no-no", "bg-bg", "hr-hr", "hr-ba", "ms-my", "ms-bn", "sl-sl", "ta-in", "vi-vn",
"el-gr", "ro-ro", "is-is", "id-id", "th-th", "lt-lt", "uk-ua", "lv-lv", "et-ee", "ca-es",
"fi-fi", "sr-ba", "sr-me", "sr-rs", "sk-sk", "nb-no", "hy-am", "bn-in", "eu-es", "gl-es",
"gu-in", "he-il", "ga-ie", "kn-in", "ml-in", "mr-in", "fa-ae", "pa-in", "te-in", "ur-pk".
:paramtype query_language: str or ~azure.search.documents.models.QueryLanguage
:keyword query_speller: A value that specified the type of the speller to use to spell-correct
individual search query terms. Possible values include: "none", "lexicon".
:paramtype query_speller: str or ~azure.search.documents.models.QuerySpellerType
:keyword query_answer: 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.
Possible values include: "none", "extractive".
:paramtype query_answer: str or ~azure.search.documents.models.QueryAnswerType
:keyword int query_answer_count: This parameter is only valid if the query type is 'semantic' and
query answer is 'extractive'.
Configures the number of answers returned. Default count is 1.
:keyword query_caption: This parameter is only valid if the query type is 'semantic'. If set, the
query returns captions extracted from key passages in the highest ranked documents.
Defaults to 'None'. Possible values include: "none", "extractive".
:paramtype query_caption: str or ~azure.search.documents.models.QueryCaptionType
:keyword bool query_caption_highlight: This parameter is only valid if the query type is 'semantic' when
query caption is set to 'extractive'. Determines whether highlighting is enabled.
Defaults to 'true'.
:keyword list[str] semantic_fields: The list of field names used for semantic search.
:keyword semantic_configuration_name: The name of the semantic configuration that will be used when
processing documents for queries of type semantic.
:paramtype semantic_configuration_name: str
:keyword list[str] select: The list of fields to retrieve. If unspecified, all fields marked as retrievable
in the schema are included.
:keyword int skip: The number of search results to skip. This value cannot be greater than 100,000.
Expand All @@ -218,41 +187,22 @@ async def search(self, search_text, **kwargs): # pylint:disable=too-many-locals
$skip to implement client-side paging of search results. If results are truncated due to
server-side paging, the response will include a continuation token that can be used to issue
another Search request for the next page of results.
:keyword 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
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.
Possible values include: "local", "global".
:paramtype scoring_statistics: str or ~azure.search.documents.models.ScoringStatistics
:keyword session_id: A value to be used to create a sticky session, which can help getting more
consistent results. As long as the same sessionId is used, a best-effort attempt will be made
to target the same replica set. Be wary that reusing the same sessionID values repeatedly can
interfere with the load balancing of the requests across replicas and adversely affect the
performance of the search service. The value used as sessionId cannot start with a '_'
character.
:paramtype session_id: str
:rtype: AsyncSearchItemPaged[dict]

.. admonition:: Example:

.. literalinclude:: ../samples/async_samples/sample_simple_query_async.py
:start-after: [START simple_query_async]
:end-before: [END simple_query_async]
:language: python
:dedent: 4
:caption: Search on a simple text term.

.. admonition:: Example:

.. literalinclude:: ../samples/async_samples/sample_filter_query_async.py
:start-after: [START filter_query_async]
:end-before: [END filter_query_async]
:language: python
:dedent: 4
:caption: Filter and sort search results.

.. admonition:: Example:

.. literalinclude:: ../samples/async_samples/sample_facet_query_async.py
:start-after: [START facet_query_async]
:end-before: [END facet_query_async]
Expand All @@ -274,29 +224,9 @@ async def search(self, search_text, **kwargs): # pylint:disable=too-many-locals
search_fields = kwargs.pop("search_fields", None)
search_fields_str = ",".join(search_fields) if search_fields else None
search_mode = kwargs.pop("search_mode", None)
query_language = kwargs.pop("query_language", None)
query_speller = kwargs.pop("query_speller", None)
select = kwargs.pop("select", None)
skip = kwargs.pop("skip", None)
top = kwargs.pop("top", None)
session_id = kwargs.pop("session_id", None)
scoring_statistics = kwargs.pop("scoring_statistics", None)

query_answer = kwargs.pop("query_answer", None)
query_answer_count = kwargs.pop("query_answer_count", None)
answers = query_answer if not query_answer_count else '{}|count-{}'.format(
query_answer, query_answer_count
)

query_caption = kwargs.pop("query_caption", None)
query_caption_highlight = kwargs.pop("query_caption_highlight", None)
captions = query_caption if not query_caption_highlight else '{}|highlight-{}'.format(
query_caption, query_caption_highlight
)

semantic_fields = kwargs.pop("semantic_fields", None)
semantic_configuration = kwargs.pop("semantic_configuration_name", None)

query = SearchQuery(
search_text=search_text,
include_total_result_count=include_total_result_count,
Expand All @@ -312,17 +242,9 @@ async def search(self, search_text, **kwargs): # pylint:disable=too-many-locals
scoring_profile=scoring_profile,
search_fields=search_fields_str,
search_mode=search_mode,
query_language=query_language,
speller=query_speller,
answers=answers,
captions=captions,
semantic_fields=",".join(semantic_fields) if semantic_fields else None,
semantic_configuration=semantic_configuration,
select=select if isinstance(select, six.string_types) else None,
skip=skip,
top=top,
session_id=session_id,
scoring_statistics=scoring_statistics
top=top
)
if isinstance(select, list):
query.select(select)
Expand Down
Loading