-
Notifications
You must be signed in to change notification settings - Fork 3.3k
update version number and API_version support #12154
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
Changes from 2 commits
a746d2c
d3b9a21
61b036c
fc5212d
123f2d6
b64ccac
13baf4e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| # ------------------------------------ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # Licensed under the MIT License. | ||
| # ------------------------------------ | ||
|
|
||
| _SUPPORTED_API_VERSIONS = [ | ||
| "2019-05-06-Preview", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I understand the PR correctly, it's to make sure this is "2020-06-03" everywhere.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We will have a separate PR to update the API version number (that will include updating auto-generated code) |
||
| ] | ||
|
|
||
| def get_api_version(kwargs, default): | ||
| # type: (Dict[str, Any]) -> str | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is the type hint correct? there are 2 params above.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch! Fixed. |
||
| api_version = kwargs.pop('api_version', None) | ||
| if api_version and api_version not in _SUPPORTED_API_VERSIONS: | ||
| versions = '\n'.join(_SUPPORTED_API_VERSIONS) | ||
| raise ValueError("Unsupported API version '{}'. Please select from:\n{}".format(api_version, versions)) | ||
| return api_version or default | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ | |
| import six | ||
|
|
||
| from azure.core.tracing.decorator import distributed_trace | ||
| from .._api_versions import get_api_version | ||
| from ._generated import SearchIndexClient | ||
| from ._generated.models import IndexBatch, IndexingResult | ||
| from ._index_documents_batch import IndexDocumentsBatch | ||
|
|
@@ -59,6 +60,8 @@ class SearchClient(HeadersMixin): | |
| :type index_name: str | ||
| :param credential: A credential to authorize search client requests | ||
| :type credential: ~azure.core.credentials.AzureKeyCredential | ||
| :keyword str api_version: | ||
| The Search API version to use for requests. Default value is "2019-05-06-Preview". | ||
|
xiangyan99 marked this conversation as resolved.
Outdated
|
||
|
|
||
| .. admonition:: Example: | ||
|
|
||
|
|
@@ -75,6 +78,7 @@ class SearchClient(HeadersMixin): | |
| def __init__(self, endpoint, index_name, credential, **kwargs): | ||
| # type: (str, str, AzureKeyCredential, **Any) -> None | ||
|
|
||
| get_api_version(kwargs, "2019-05-06-Preview") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So I guess here it's used has a "check", then I would split a "check" and a "get" into two different methods, with "get" calling check first. I find it easier to read intent
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's optional feedback, I let you decide if that makes the code less efficient |
||
| self._endpoint = endpoint # type: str | ||
| self._index_name = index_name # type: str | ||
| self._credential = credential # type: AzureKeyCredential | ||
|
|
@@ -138,6 +142,68 @@ def search(self, search_text, **kwargs): | |
|
|
||
| :param str search_text: A full-text search query expression; Use "*" or omit this parameter to | ||
| match all documents. | ||
| :keyword include_total_result_count: A value that specifies whether to fetch the total count of | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tg-msft, shouldn't this be
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. include_total_result_count is from the swagger. Do we want to change it? |
||
| results. Default is false. Setting this value to true may have a performance impact. Note that | ||
| the count returned is an approximation. | ||
| :type include_total_result_count: bool | ||
|
xiangyan99 marked this conversation as resolved.
Outdated
|
||
| :keyword facets: The list of facet expressions to apply to the search query. Each facet | ||
| expression contains a field name, optionally followed by a comma-separated list of name:value | ||
| pairs. | ||
| :type facets: list[str] | ||
| :keyword filter: The OData $filter expression to apply to the search query. | ||
| :type filter: str | ||
| :keyword highlight_fields: The list of field names to use for hit highlights. Only searchable | ||
| fields can be used for hit highlighting. | ||
| :type highlight_fields: list[str] | ||
| :keyword highlight_post_tag: A string tag that is appended to hit highlights. Must be set with | ||
| highlightPreTag. Default is </em>. | ||
| :type highlight_post_tag: str | ||
| :keyword highlight_pre_tag: A string tag that is prepended to hit highlights. Must be set with | ||
| highlightPostTag. Default is <em>. | ||
| :type highlight_pre_tag: str | ||
| :keyword minimum_coverage: A number between 0 and 100 indicating the percentage of the index that | ||
| must be covered by a search query in order for the query to be reported as a success. This | ||
| parameter can be useful for ensuring search availability even for services with only one | ||
| replica. The default is 100. | ||
| :type minimum_coverage: float | ||
| :keyword order_by: The list of OData $orderby expressions by which to sort the results. Each | ||
| expression can be either a field name or a call to either the geo.distance() or the | ||
| search.score() functions. Each expression can be followed by asc to indicate ascending, and | ||
| desc to indicate descending. The default is ascending order. Ties will be broken by the match | ||
| scores of documents. If no OrderBy is specified, the default sort order is descending by | ||
| document match score. There can be at most 32 $orderby clauses. | ||
| :type order_by: list[str] | ||
| :keyword 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'. | ||
| :type query_type: str or ~search_index_client.models.QueryType | ||
| :keyword 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 | ||
| profile defines a function with a parameter called 'mylocation' the parameter string would be | ||
| "mylocation--122.2,44.8" (without the quotes). | ||
| :type scoring_parameters: list[str] | ||
| :keyword scoring_profile: The name of a scoring profile to evaluate match scores for matching | ||
| documents in order to sort the results. | ||
| :type scoring_profile: str | ||
| :keyword search_fields: The list of field names to which to scope the full-text search. When | ||
| 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] | ||
| :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'. | ||
| :type search_mode: str or ~search_index_client.models.SearchMode | ||
| :keyword select: The list of fields to retrieve. If unspecified, all fields marked as retrievable | ||
| in the schema are included. | ||
| :type select: list[str] | ||
| :keyword skip: The number of search results to skip. This value cannot be greater than 100,000. | ||
| If you need to scan documents in sequence, but cannot use $skip due to this limitation, | ||
| consider using $orderby on a totally-ordered key and $filter with a range query instead. | ||
| :type skip: int | ||
| :keyword top: The number of search results to retrieve. This can be used in conjunction with | ||
| $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. | ||
| :type top: int | ||
| :rtype: SearchItemPaged[dict] | ||
|
|
||
| .. admonition:: Example: | ||
|
|
@@ -217,6 +283,41 @@ def suggest(self, search_text, suggester_name, **kwargs): | |
| character, and no more than 100 characters. | ||
| :param str suggester_name: Required. The name of the suggester as specified in the suggesters | ||
| collection that's part of the index definition. | ||
| :keyword filter: An OData expression that filters the documents considered for suggestions. | ||
| :type filter: str | ||
| :keyword use_fuzzy_matching: A value indicating whether to use fuzzy matching for the suggestions | ||
| query. Default is false. When set to true, the query will find terms even if there's a | ||
| substituted or missing character in the search text. While this provides a better experience in | ||
| some scenarios, it comes at a performance cost as fuzzy suggestions queries are slower and | ||
| consume more resources. | ||
| :type use_fuzzy_matching: bool | ||
| :keyword highlight_post_tag: A string tag that is appended to hit highlights. Must be set with | ||
| highlightPreTag. If omitted, hit highlighting of suggestions is disabled. | ||
| :type highlight_post_tag: str | ||
| :keyword highlight_pre_tag: A string tag that is prepended to hit highlights. Must be set with | ||
| highlightPostTag. If omitted, hit highlighting of suggestions is disabled. | ||
| :type highlight_pre_tag: str | ||
| :keyword minimum_coverage: A number between 0 and 100 indicating the percentage of the index that | ||
| must be covered by a suggestions query in order for the query to be reported as a success. This | ||
| parameter can be useful for ensuring search availability even for services with only one | ||
| replica. The default is 80. | ||
| :type minimum_coverage: float | ||
| :keyword order_by: The list of OData $orderby expressions by which to sort the results. Each | ||
| expression can be either a field name or a call to either the geo.distance() or the | ||
| search.score() functions. Each expression can be followed by asc to indicate ascending, or desc | ||
| to indicate descending. The default is ascending order. Ties will be broken by the match scores | ||
| of documents. If no $orderby is specified, the default sort order is descending by document | ||
| match score. There can be at most 32 $orderby clauses. | ||
| :type order_by: list[str] | ||
| :keyword search_fields: The list of field names to search for the specified search text. Target | ||
| fields must be included in the specified suggester. | ||
| :type search_fields: list[str] | ||
| :keyword select: The list of fields to retrieve. If unspecified, only the key field will be | ||
| included in the results. | ||
| :type select: list[str] | ||
| :keyword top: The number of suggestions to retrieve. The value must be a number between 1 and | ||
| 100. The default is 5. | ||
| :type top: int | ||
| :rtype: List[dict] | ||
|
|
||
| .. admonition:: Example: | ||
|
|
@@ -266,6 +367,36 @@ def autocomplete(self, search_text, suggester_name, **kwargs): | |
| :param str search_text: The search text on which to base autocomplete results. | ||
| :param str suggester_name: The name of the suggester as specified in the suggesters | ||
| collection that's part of the index definition. | ||
| :keyword autocomplete_mode: Specifies the mode for Autocomplete. The default is 'oneTerm'. Use | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In .NET we just have this as
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am ok to use mode, just want to confirm because autocomplete_mode is from swagger. |
||
| 'twoTerms' to get shingles and 'oneTermWithContext' to use the current context while producing | ||
| auto-completed terms. Possible values include: 'oneTerm', 'twoTerms', 'oneTermWithContext'. | ||
| :type autocomplete_mode: str or ~search_index_client.models.AutocompleteMode | ||
| :keyword filter: An OData expression that filters the documents used to produce completed terms | ||
| for the Autocomplete result. | ||
| :type filter: str | ||
| :keyword use_fuzzy_matching: A value indicating whether to use fuzzy matching for the | ||
| autocomplete query. Default is false. When set to true, the query will find terms even if | ||
| there's a substituted or missing character in the search text. While this provides a better | ||
| experience in some scenarios, it comes at a performance cost as fuzzy autocomplete queries are | ||
| slower and consume more resources. | ||
| :type use_fuzzy_matching: bool | ||
| :keyword highlight_post_tag: A string tag that is appended to hit highlights. Must be set with | ||
| highlightPreTag. If omitted, hit highlighting is disabled. | ||
| :type highlight_post_tag: str | ||
| :keyword highlight_pre_tag: A string tag that is prepended to hit highlights. Must be set with | ||
| highlightPostTag. If omitted, hit highlighting is disabled. | ||
| :type highlight_pre_tag: str | ||
| :keyword minimum_coverage: A number between 0 and 100 indicating the percentage of the index that | ||
| must be covered by an autocomplete query in order for the query to be reported as a success. | ||
| This parameter can be useful for ensuring search availability even for services with only one | ||
| replica. The default is 80. | ||
| :type minimum_coverage: float | ||
| :keyword search_fields: The list of field names to consider when querying for auto-completed | ||
| terms. Target fields must be included in the specified suggester. | ||
| :type search_fields: list[str] | ||
| :keyword top: The number of auto-completed terms to retrieve. This must be a value between 1 and | ||
| 100. The default is 5. | ||
| :type top: int | ||
| :rtype: List[dict] | ||
|
|
||
| .. admonition:: Example: | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.