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

update version number and API_version support #12154

Merged
merged 7 commits into from
Jun 25, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 35 additions & 12 deletions sdk/search/azure-search-documents/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
# Release History

## 11.0.0 (2020-07-07)

- Exposed more models:
xiangyan99 marked this conversation as resolved.
Show resolved Hide resolved

* BM25SimilarityAlgorithm
* ClassicSimilarityAlgorithm
* EdgeNGramTokenFilterSide
* EntityCategory
* EntityRecognitionSkillLanguage
* FieldMapping
* FieldMappingFunction
* ImageAnalysisSkillLanguage
* ImageDetail
* IndexerExecutionStatus
* IndexerStatus
* KeyPhraseExtractionSkillLanguage
* MicrosoftStemmingTokenizerLanguage
* MicrosoftTokenizerLanguage
* OcrSkillLanguage
* PhoneticEncoder
* ScoringFunctionAggregation
* ScoringFunctionInterpolation

## 1.0.0b4 (2020-06-09)

**Breaking Changes**
Expand All @@ -10,18 +33,18 @@
- Now Search Synonym Map creation/update returns a model #11514
- Renaming #11565

SearchIndexerDataSource -> SearchIndexerDataSourceConnection
SearchField.SynonymMaps -> SearchField.SynonymMapNames
SearchField.Analyzer -> SearchField.AnalyzerName
SearchField.IndexAnalyzer -> SearchField.IndexAnalyzerName
SearchField.SearchAnalyzer -> SearchField.SearchAnalyzerName
SearchableField.SynonymMaps -> SearchableField.SynonymMapNames
SearchableField.Analyzer -> SearchableField.AnalyzerName
SearchableField.IndexAnalyzer -> SearchableField.IndexAnalyzerName
SearchableField.SearchAnalyzer -> SearchableField.SearchAnalyzerName
Similarity -> SimilarityAlgorithm
Suggester -> SearchSuggester
PathHierarchyTokenizerV2 -> PathHierarchyTokenizer
* SearchIndexerDataSource -> SearchIndexerDataSourceConnection
* SearchField.SynonymMaps -> SearchField.SynonymMapNames
* SearchField.Analyzer -> SearchField.AnalyzerName
* SearchField.IndexAnalyzer -> SearchField.IndexAnalyzerName
* SearchField.SearchAnalyzer -> SearchField.SearchAnalyzerName
* SearchableField.SynonymMaps -> SearchableField.SynonymMapNames
* SearchableField.Analyzer -> SearchableField.AnalyzerName
* SearchableField.IndexAnalyzer -> SearchableField.IndexAnalyzerName
* SearchableField.SearchAnalyzer -> SearchableField.SearchAnalyzerName
* Similarity -> SimilarityAlgorithm
* Suggester -> SearchSuggester
* PathHierarchyTokenizerV2 -> PathHierarchyTokenizer
- Renamed DataSource methods to DataSourceConnection #11693
- Autocomplete & suggest methods now takes arguments search_text & suggester_name rather than query objects #11747
- Create_or_updates methods does not support partial updates #11800
Expand Down
22 changes: 21 additions & 1 deletion sdk/search/azure-search-documents/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ client = SearchClient(endpoint=endpoint,
credential=credential)

# Let's get the top 5 jobs related to Microsoft
results = client.search(search_text="Microsoft", include_total_result_count=5)
results = client.search(search_text="Microsoft", top=5)

for result in results:
# Print out the title and job description
Expand Down Expand Up @@ -325,6 +325,26 @@ print("Upload of new document succeeded: {}".format(result[0].succeeded))
```


### Async APIs
This library includes a complete async API supported on Python 3.5+. To use it, you must
first install an async transport, such as [aiohttp](https://pypi.org/project/aiohttp/).
See
[azure-core documentation](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/core/azure-core/README.md#transport)
for more information.


```py
from azure.search.documents.aio import SearchClient

client = SearchClient(
endpoint, index_name, AzureKeyCredential(api_key)
xiangyan99 marked this conversation as resolved.
Show resolved Hide resolved
)
xiangyan99 marked this conversation as resolved.
Show resolved Hide resolved

async with client:
results = await client.search(search_text="hotel")
xiangyan99 marked this conversation as resolved.
Show resolved Hide resolved
...


## Troubleshooting

### General
Expand Down
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",
Copy link
Member

Choose a reason for hiding this comment

The 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.

Copy link
Member Author

@xiangyan99 xiangyan99 Jun 25, 2020

Choose a reason for hiding this comment

The 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the type hint correct? there are 2 params above.

Copy link
Member Author

Choose a reason for hiding this comment

The 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
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Show resolved Hide resolved

.. admonition:: Example:

Expand All @@ -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")
Copy link
Member

Choose a reason for hiding this comment

The 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

Copy link
Member

Choose a reason for hiding this comment

The 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
Expand Down Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tg-msft, shouldn't this be include_total_count? Or was that one of the things we were asked to change? I don't see it changed in .NET yet.

Copy link
Member Author

Choose a reason for hiding this comment

The 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.
Show resolved Hide resolved
: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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In .NET we just have this as mode. @tg-msft, should it match in this case or is this idiomatically acceptable?

/cc @johanste

Copy link
Member Author

Choose a reason for hiding this comment

The 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:
Expand Down
Loading