diff --git a/sdk/search/azure-search-documents/CHANGELOG.md b/sdk/search/azure-search-documents/CHANGELOG.md index 220b27aae6c8..9037d1d6c1cb 100644 --- a/sdk/search/azure-search-documents/CHANGELOG.md +++ b/sdk/search/azure-search-documents/CHANGELOG.md @@ -8,6 +8,8 @@ - Added properties to `SearchIndexerDataSourceConnection`: `identity`, `encryption_key`. - Added `select` property to the following `SearchIndexClient` operations: `get_synonym_maps`, `list_indexes`. - Added `select` property to the following `SearchIndexersClient` operations: `get_data_source_connections`, `get_indexers`, `get_skillsets`. +- Added operations to `SearchIndexerClient`: `reset_skills`, `reset_documents`. +- Added model: `DocumentKeysOrIds` ### Other Changes diff --git a/sdk/search/azure-search-documents/azure/search/documents/indexes/_search_indexer_client.py b/sdk/search/azure-search-documents/azure/search/documents/indexes/_search_indexer_client.py index 03c351a68f3a..6d507807c632 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/indexes/_search_indexer_client.py +++ b/sdk/search/azure-search-documents/azure/search/documents/indexes/_search_indexer_client.py @@ -27,7 +27,7 @@ if TYPE_CHECKING: # pylint:disable=unused-import,ungrouped-imports - from ._generated.models import SearchIndexer, SearchIndexerStatus + from ._generated.models import SearchIndexer, SearchIndexerStatus, DocumentKeysOrIds from typing import Any, Optional, Sequence, Union from azure.core.credentials import TokenCredential @@ -285,6 +285,30 @@ def reset_indexer(self, name, **kwargs): kwargs["headers"] = self._merge_client_headers(kwargs.get("headers")) self._client.indexers.reset(name, **kwargs) + @distributed_trace + def reset_documents(self, indexer, keys_or_ids, **kwargs): + # type: (Union[str, SearchIndexer], DocumentKeysOrIds, **Any) -> None + """Resets specific documents in the datasource to be selectively re-ingested by the indexer. + + :param indexer: The indexer to reset documents for. + :type indexer: str or ~azure.search.documents.indexes.models.SearchIndexer + :param keys_or_ids: + :type keys_or_ids: ~azure.search.documents.indexes.models.DocumentKeysOrIds + :return: None, or the result of cls(response) + :keyword overwrite: If false, keys or ids will be appended to existing ones. If true, only the + keys or ids in this payload will be queued to be re-ingested. The default is false. + :paramtype overwrite: bool + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + kwargs["headers"] = self._merge_client_headers(kwargs.get("headers")) + kwargs["keys_or_ids"] = keys_or_ids + try: + name = indexer.name + except AttributeError: + name = indexer + return self._client.indexers.reset_docs(name, **kwargs) + @distributed_trace def get_indexer_status(self, name, **kwargs): # type: (str, **Any) -> SearchIndexerStatus @@ -547,8 +571,8 @@ def delete_skillset(self, skillset, **kwargs): the SearchIndexerSkillset model must be provided instead of the name. It is enough to provide the name of the skillset to delete unconditionally - :param name: The SearchIndexerSkillset to delete - :type name: str or ~azure.search.documents.indexes.models.SearchIndexerSkillset + :param skillset: The SearchIndexerSkillset to delete + :type skillset: str or ~azure.search.documents.indexes.models.SearchIndexerSkillset :keyword match_condition: The match condition to use upon the etag :type match_condition: ~azure.core.MatchConditions @@ -635,6 +659,26 @@ def create_or_update_skillset(self, skillset, **kwargs): ) return SearchIndexerSkillset._from_generated(result) # pylint:disable=protected-access + @distributed_trace + def reset_skills(self, skillset, skill_names, **kwargs): + # type: (Union[str, SearchIndexerSkillset], List[str], **Any) -> None + """Reset an existing skillset in a search service. + + :param skillset: The SearchIndexerSkillset to reset + :type skillset: str or ~azure.search.documents.indexes.models.SearchIndexerSkillset + :param skill_names: the names of skills to be reset. + :type skill_names: list[str] + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + kwargs["headers"] = self._merge_client_headers(kwargs.get("headers")) + try: + name = skillset.name + except AttributeError: + name = skillset + return self._client.skillsets.reset_skills(name, skill_names, **kwargs) + def _validate_skillset(skillset): """Validates any multi-version skills in the skillset to verify that unsupported parameters are not supplied by the user. diff --git a/sdk/search/azure-search-documents/azure/search/documents/indexes/aio/_search_indexer_client.py b/sdk/search/azure-search-documents/azure/search/documents/indexes/aio/_search_indexer_client.py index 92f986603834..83836d099c1f 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/indexes/aio/_search_indexer_client.py +++ b/sdk/search/azure-search-documents/azure/search/documents/indexes/aio/_search_indexer_client.py @@ -25,7 +25,7 @@ if TYPE_CHECKING: # pylint:disable=unused-import,ungrouped-imports - from .._generated.models import SearchIndexer, SearchIndexerStatus + from .._generated.models import SearchIndexer, SearchIndexerStatus, DocumentKeysOrIds from typing import Any, Optional, Sequence from azure.core.credentials_async import AsyncTokenCredential @@ -278,6 +278,31 @@ async def reset_indexer(self, name, **kwargs): kwargs["headers"] = self._merge_client_headers(kwargs.get("headers")) await self._client.indexers.reset(name, **kwargs) + @distributed_trace_async + async def reset_documents(self, indexer, keys_or_ids, **kwargs): + # type: (Union[str, SearchIndexer], DocumentKeysOrIds, **Any) -> None + """Resets specific documents in the datasource to be selectively re-ingested by the indexer. + + :param indexer: The indexer to reset documents for. + :type indexer: str or ~azure.search.documents.indexes.models.SearchIndexer + :param keys_or_ids: + :type keys_or_ids: ~azure.search.documents.indexes.models.DocumentKeysOrIds + :return: None, or the result of cls(response) + :keyword overwrite: If false, keys or ids will be appended to existing ones. If true, only the + keys or ids in this payload will be queued to be re-ingested. The default is false. + :paramtype overwrite: bool + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + kwargs["headers"] = self._merge_client_headers(kwargs.get("headers")) + kwargs["keys_or_ids"] = keys_or_ids + try: + name = indexer.name + except AttributeError: + name = indexer + result = await self._client.indexers.reset_docs(name, **kwargs) + return result + @distributed_trace_async async def get_indexer_status(self, name, **kwargs): # type: (str, **Any) -> SearchIndexerStatus @@ -535,8 +560,8 @@ async def delete_skillset(self, skillset, **kwargs): the SearchIndexerSkillset model must be provided instead of the name. It is enough to provide the name of the skillset to delete unconditionally - :param name: The SearchIndexerSkillset to delete - :type name: str or ~azure.search.documents.indexes.models.SearchIndexerSkillset + :param skillset: The SearchIndexerSkillset to delete + :type skillset: str or ~azure.search.documents.indexes.models.SearchIndexerSkillset :keyword match_condition: The match condition to use upon the etag :type match_condition: ~azure.core.MatchConditions @@ -619,3 +644,24 @@ async def create_or_update_skillset(self, skillset, **kwargs): **kwargs ) return SearchIndexerSkillset._from_generated(result) # pylint:disable=protected-access + + @distributed_trace_async + async def reset_skills(self, skillset, skill_names, **kwargs): + # type: (Union[str, SearchIndexerSkillset], List[str], **Any) -> None + """Reset an existing skillset in a search service. + + :param skillset: The SearchIndexerSkillset to reset + :type skillset: str or ~azure.search.documents.indexes.models.SearchIndexerSkillset + :param skill_names: the names of skills to be reset. + :type skill_names: list[str] + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + kwargs["headers"] = self._merge_client_headers(kwargs.get("headers")) + try: + name = skillset.name + except AttributeError: + name = skillset + result = await self._client.skillsets.reset_skills(name, skill_names, **kwargs) + return result diff --git a/sdk/search/azure-search-documents/azure/search/documents/indexes/models/__init__.py b/sdk/search/azure-search-documents/azure/search/documents/indexes/models/__init__.py index 58af2c002d11..d2b6c5d64960 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/indexes/models/__init__.py +++ b/sdk/search/azure-search-documents/azure/search/documents/indexes/models/__init__.py @@ -52,6 +52,7 @@ DistanceScoringFunction, DistanceScoringParameters, DocumentExtractionSkill, + DocumentKeysOrIds, EdgeNGramTokenFilter, EdgeNGramTokenizer, EdgeNGramTokenFilterSide, @@ -199,6 +200,7 @@ "DistanceScoringFunction", "DistanceScoringParameters", "DocumentExtractionSkill", + "DocumentKeysOrIds", "EdgeNGramTokenFilter", "EdgeNGramTokenizer", "ElisionTokenFilter", diff --git a/sdk/search/azure-search-documents/tests/async_tests/recordings/test_search_index_client_skillset_live_async.test_create_skillset.yaml b/sdk/search/azure-search-documents/tests/async_tests/recordings/test_search_index_client_skillset_live_async.test_create_skillset.yaml index 3d61e40be4f7..ef03d1f947e9 100644 --- a/sdk/search/azure-search-documents/tests/async_tests/recordings/test_search_index_client_skillset_live_async.test_create_skillset.yaml +++ b/sdk/search/azure-search-documents/tests/async_tests/recordings/test_search_index_client_skillset_live_async.test_create_skillset.yaml @@ -1,45 +1,46 @@ interactions: - request: body: '{"name": "test-ss", "description": "desc", "skills": [{"@odata.type": "#Microsoft.Skills.Text.EntityRecognitionSkill", - "inputs": [{"name": "text", "source": "/document/content"}], "outputs": [{"name": - "organizations", "targetName": "organizationsS1"}], "includeTypelessEntities": - true}, {"@odata.type": "#Microsoft.Skills.Text.V3.EntityRecognitionSkill", "inputs": - [{"name": "text", "source": "/document/content"}], "outputs": [{"name": "organizations", - "targetName": "organizationsS2"}], "modelVersion": "3"}, {"@odata.type": "#Microsoft.Skills.Text.SentimentSkill", + "name": "skill1", "inputs": [{"name": "text", "source": "/document/content"}], + "outputs": [{"name": "organizations", "targetName": "organizationsS1"}], "includeTypelessEntities": + true}, {"@odata.type": "#Microsoft.Skills.Text.V3.EntityRecognitionSkill", "name": + "skill2", "inputs": [{"name": "text", "source": "/document/content"}], "outputs": + [{"name": "organizations", "targetName": "organizationsS2"}], "modelVersion": + "3"}, {"@odata.type": "#Microsoft.Skills.Text.SentimentSkill", "name": "skill3", "inputs": [{"name": "text", "source": "/document/content"}], "outputs": [{"name": "score", "targetName": "scoreS3"}]}, {"@odata.type": "#Microsoft.Skills.Text.V3.SentimentSkill", - "inputs": [{"name": "text", "source": "/document/content"}], "outputs": [{"name": - "confidenceScores", "targetName": "scoreS4"}], "includeOpinionMining": true}, - {"@odata.type": "#Microsoft.Skills.Text.V3.EntityLinkingSkill", "inputs": [{"name": - "text", "source": "/document/content"}], "outputs": [{"name": "entities", "targetName": - "entitiesS5"}], "minimumPrecision": 0.5}]}' + "name": "skill4", "inputs": [{"name": "text", "source": "/document/content"}], + "outputs": [{"name": "confidenceScores", "targetName": "scoreS4"}], "includeOpinionMining": + true}, {"@odata.type": "#Microsoft.Skills.Text.V3.EntityLinkingSkill", "name": + "skill5", "inputs": [{"name": "text", "source": "/document/content"}], "outputs": + [{"name": "entities", "targetName": "entitiesS5"}], "minimumPrecision": 0.5}]}' headers: Accept: - application/json;odata.metadata=minimal Content-Length: - - '1121' + - '1211' Content-Type: - application/json User-Agent: - - azsdk-python-search-documents/11.3.0b3 Python/3.9.2 (Windows-10-10.0.19041-SP0) + - azsdk-python-search-documents/11.3.0b5 Python/3.9.2 (Windows-10-10.0.19041-SP0) method: POST uri: https://search75151acc.search.windows.net/skillsets?api-version=2021-04-30-Preview response: body: - string: '{"@odata.context":"https://search75151acc.search.windows.net/$metadata#skillsets/$entity","@odata.etag":"\"0x8D96E6933515CD0\"","name":"test-ss","description":"desc","skills":[{"@odata.type":"#Microsoft.Skills.Text.EntityRecognitionSkill","name":null,"description":null,"context":null,"categories":[],"defaultLanguageCode":null,"minimumPrecision":null,"includeTypelessEntities":true,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"organizations","targetName":"organizationsS1"}]},{"@odata.type":"#Microsoft.Skills.Text.V3.EntityRecognitionSkill","name":null,"description":null,"context":null,"categories":[],"defaultLanguageCode":null,"minimumPrecision":null,"modelVersion":"3","inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"organizations","targetName":"organizationsS2"}]},{"@odata.type":"#Microsoft.Skills.Text.SentimentSkill","name":null,"description":null,"context":null,"defaultLanguageCode":null,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"score","targetName":"scoreS3"}]},{"@odata.type":"#Microsoft.Skills.Text.V3.SentimentSkill","name":null,"description":null,"context":null,"defaultLanguageCode":null,"modelVersion":null,"includeOpinionMining":true,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"confidenceScores","targetName":"scoreS4"}]},{"@odata.type":"#Microsoft.Skills.Text.V3.EntityLinkingSkill","name":null,"description":null,"context":null,"defaultLanguageCode":null,"minimumPrecision":0.5,"modelVersion":null,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"entities","targetName":"entitiesS5"}]}],"cognitiveServices":null,"knowledgeStore":null,"encryptionKey":null}' + string: '{"@odata.context":"https://search75151acc.search.windows.net/$metadata#skillsets/$entity","@odata.etag":"\"0x8D99B0399B12612\"","name":"test-ss","description":"desc","skills":[{"@odata.type":"#Microsoft.Skills.Text.EntityRecognitionSkill","name":"skill1","description":null,"context":null,"categories":[],"defaultLanguageCode":null,"minimumPrecision":null,"includeTypelessEntities":true,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"organizations","targetName":"organizationsS1"}]},{"@odata.type":"#Microsoft.Skills.Text.V3.EntityRecognitionSkill","name":"skill2","description":null,"context":null,"categories":[],"defaultLanguageCode":null,"minimumPrecision":null,"modelVersion":"3","inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"organizations","targetName":"organizationsS2"}]},{"@odata.type":"#Microsoft.Skills.Text.SentimentSkill","name":"skill3","description":null,"context":null,"defaultLanguageCode":null,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"score","targetName":"scoreS3"}]},{"@odata.type":"#Microsoft.Skills.Text.V3.SentimentSkill","name":"skill4","description":null,"context":null,"defaultLanguageCode":null,"modelVersion":null,"includeOpinionMining":true,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"confidenceScores","targetName":"scoreS4"}]},{"@odata.type":"#Microsoft.Skills.Text.V3.EntityLinkingSkill","name":"skill5","description":null,"context":null,"defaultLanguageCode":null,"minimumPrecision":0.5,"modelVersion":null,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"entities","targetName":"entitiesS5"}]}],"cognitiveServices":null,"knowledgeStore":null,"encryptionKey":null}' headers: cache-control: no-cache - content-length: '1894' + content-length: '1914' content-type: application/json; odata.metadata=minimal - date: Thu, 02 Sep 2021 23:27:16 GMT - elapsed-time: '200' - etag: W/"0x8D96E6933515CD0" + date: Fri, 29 Oct 2021 17:43:21 GMT + elapsed-time: '2316' + etag: W/"0x8D99B0399B12612" expires: '-1' location: https://search75151acc.search.windows.net/skillsets('test-ss')?api-version=2021-04-30-Preview odata-version: '4.0' pragma: no-cache preference-applied: odata.include-annotations="*" - request-id: 5036e3d3-0c45-11ec-89fe-74c63bed1137 + request-id: b51a3cc3-38df-11ec-aeae-74c63bed1137 strict-transport-security: max-age=15724800; includeSubDomains status: code: 201 @@ -51,28 +52,55 @@ interactions: Accept: - application/json;odata.metadata=minimal User-Agent: - - azsdk-python-search-documents/11.3.0b3 Python/3.9.2 (Windows-10-10.0.19041-SP0) + - azsdk-python-search-documents/11.3.0b5 Python/3.9.2 (Windows-10-10.0.19041-SP0) method: GET uri: https://search75151acc.search.windows.net/skillsets?api-version=2021-04-30-Preview response: body: - string: '{"@odata.context":"https://search75151acc.search.windows.net/$metadata#skillsets","value":[{"@odata.etag":"\"0x8D96E6933515CD0\"","name":"test-ss","description":"desc","skills":[{"@odata.type":"#Microsoft.Skills.Text.EntityRecognitionSkill","name":"#1","description":null,"context":"/document","categories":["Person","Quantity","Organization","URL","Email","Location","DateTime"],"defaultLanguageCode":"en","minimumPrecision":null,"includeTypelessEntities":true,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"organizations","targetName":"organizationsS1"}]},{"@odata.type":"#Microsoft.Skills.Text.V3.EntityRecognitionSkill","name":"#2","description":null,"context":"/document","categories":["Product","Phone - Number","Person","Quantity","IP Address","Organization","URL","Email","Event","Skill","Location","PersonType","Address","DateTime"],"defaultLanguageCode":"en","minimumPrecision":null,"modelVersion":"3","inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"organizations","targetName":"organizationsS2"}]},{"@odata.type":"#Microsoft.Skills.Text.SentimentSkill","name":"#3","description":null,"context":"/document","defaultLanguageCode":"en","inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"score","targetName":"scoreS3"}]},{"@odata.type":"#Microsoft.Skills.Text.V3.SentimentSkill","name":"#4","description":null,"context":"/document","defaultLanguageCode":"en","modelVersion":null,"includeOpinionMining":true,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"confidenceScores","targetName":"scoreS4"}]},{"@odata.type":"#Microsoft.Skills.Text.V3.EntityLinkingSkill","name":"#5","description":null,"context":"/document","defaultLanguageCode":"en","minimumPrecision":0.5,"modelVersion":null,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"entities","targetName":"entitiesS5"}]}],"cognitiveServices":null,"knowledgeStore":null,"encryptionKey":null}]}' + string: '{"@odata.context":"https://search75151acc.search.windows.net/$metadata#skillsets","value":[{"@odata.etag":"\"0x8D99B0399B12612\"","name":"test-ss","description":"desc","skills":[{"@odata.type":"#Microsoft.Skills.Text.EntityRecognitionSkill","name":"skill1","description":null,"context":"/document","categories":["Person","Quantity","Organization","URL","Email","Location","DateTime"],"defaultLanguageCode":"en","minimumPrecision":null,"includeTypelessEntities":true,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"organizations","targetName":"organizationsS1"}]},{"@odata.type":"#Microsoft.Skills.Text.V3.EntityRecognitionSkill","name":"skill2","description":null,"context":"/document","categories":["Product","PhoneNumber","Person","Quantity","Organization","IPAddress","URL","Email","Event","Skill","Location","PersonType","Address","DateTime"],"defaultLanguageCode":"en","minimumPrecision":null,"modelVersion":"3","inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"organizations","targetName":"organizationsS2"}]},{"@odata.type":"#Microsoft.Skills.Text.SentimentSkill","name":"skill3","description":null,"context":"/document","defaultLanguageCode":"en","inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"score","targetName":"scoreS3"}]},{"@odata.type":"#Microsoft.Skills.Text.V3.SentimentSkill","name":"skill4","description":null,"context":"/document","defaultLanguageCode":"en","modelVersion":null,"includeOpinionMining":true,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"confidenceScores","targetName":"scoreS4"}]},{"@odata.type":"#Microsoft.Skills.Text.V3.EntityLinkingSkill","name":"skill5","description":null,"context":"/document","defaultLanguageCode":"en","minimumPrecision":0.5,"modelVersion":null,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"entities","targetName":"entitiesS5"}]}],"cognitiveServices":null,"knowledgeStore":null,"encryptionKey":null}]}' headers: cache-control: no-cache content-length: '795' content-type: application/json; odata.metadata=minimal - date: Thu, 02 Sep 2021 23:27:16 GMT - elapsed-time: '39' + date: Fri, 29 Oct 2021 17:43:21 GMT + elapsed-time: '115' expires: '-1' odata-version: '4.0' pragma: no-cache preference-applied: odata.include-annotations="*" - request-id: 507bb3fc-0c45-11ec-b9ee-74c63bed1137 + request-id: b6a87364-38df-11ec-bfe5-74c63bed1137 strict-transport-security: max-age=15724800; includeSubDomains vary: Accept-Encoding status: code: 200 message: OK url: https://search75151acc.search.windows.net/skillsets?api-version=2021-04-30-Preview +- request: + body: '{"skillNames": ["skill1", "skill2", "skill3", "skill4", "skill5"]}' + headers: + Accept: + - application/json;odata.metadata=minimal + Content-Length: + - '66' + Content-Type: + - application/json + User-Agent: + - azsdk-python-search-documents/11.3.0b5 Python/3.9.2 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://search75151acc.search.windows.net/skillsets('test-ss')/search.resetskills?api-version=2021-04-30-Preview + response: + body: + string: '' + headers: + cache-control: no-cache + date: Fri, 29 Oct 2021 17:43:21 GMT + elapsed-time: '75' + expires: '-1' + pragma: no-cache + request-id: b6c43de3-38df-11ec-93a9-74c63bed1137 + strict-transport-security: max-age=15724800; includeSubDomains + status: + code: 204 + message: No Content + url: https://search75151acc.search.windows.net/skillsets('test-ss')/search.resetskills?api-version=2021-04-30-Preview version: 1 diff --git a/sdk/search/azure-search-documents/tests/async_tests/test_search_index_client_skillset_live_async.py b/sdk/search/azure-search-documents/tests/async_tests/test_search_index_client_skillset_live_async.py index 1544e53a34cb..62822e042f33 100644 --- a/sdk/search/azure-search-documents/tests/async_tests/test_search_index_client_skillset_live_async.py +++ b/sdk/search/azure-search-documents/tests/async_tests/test_search_index_client_skillset_live_async.py @@ -59,31 +59,36 @@ async def test_create_skillset(self, api_key, endpoint, index_name, **kwargs): client = SearchIndexerClient(endpoint, AzureKeyCredential(api_key)) name = "test-ss" - s1 = EntityRecognitionSkill(inputs=[InputFieldMappingEntry(name="text", source="/document/content")], + s1 = EntityRecognitionSkill(name="skill1", + inputs=[InputFieldMappingEntry(name="text", source="/document/content")], outputs=[OutputFieldMappingEntry(name="organizations", target_name="organizationsS1")], description="Skill Version 1", model_version="1", include_typeless_entities=True) - s2 = EntityRecognitionSkill(inputs=[InputFieldMappingEntry(name="text", source="/document/content")], + s2 = EntityRecognitionSkill(name="skill2", + inputs=[InputFieldMappingEntry(name="text", source="/document/content")], outputs=[OutputFieldMappingEntry(name="organizations", target_name="organizationsS2")], skill_version=EntityRecognitionSkillVersion.LATEST, description="Skill Version 3", model_version="3", include_typeless_entities=True) - s3 = SentimentSkill(inputs=[InputFieldMappingEntry(name="text", source="/document/content")], + s3 = SentimentSkill(name="skill3", + inputs=[InputFieldMappingEntry(name="text", source="/document/content")], outputs=[OutputFieldMappingEntry(name="score", target_name="scoreS3")], skill_version=SentimentSkillVersion.V1, description="Sentiment V1", include_opinion_mining=True) - s4 = SentimentSkill(inputs=[InputFieldMappingEntry(name="text", source="/document/content")], + s4 = SentimentSkill(name="skill4", + inputs=[InputFieldMappingEntry(name="text", source="/document/content")], outputs=[OutputFieldMappingEntry(name="confidenceScores", target_name="scoreS4")], skill_version=SentimentSkillVersion.V3, description="Sentiment V3", include_opinion_mining=True) - s5 = EntityLinkingSkill(inputs=[InputFieldMappingEntry(name="text", source="/document/content")], + s5 = EntityLinkingSkill(name="skill5", + inputs=[InputFieldMappingEntry(name="text", source="/document/content")], outputs=[OutputFieldMappingEntry(name="entities", target_name="entitiesS5")], minimum_precision=0.5) @@ -108,6 +113,8 @@ async def test_create_skillset(self, api_key, endpoint, index_name, **kwargs): assert len(await client.get_skillsets()) == 1 + await client.reset_skills(result, [x.name for x in result.skills]) + @SearchResourceGroupPreparer(random_name_enabled=True) @SearchServicePreparer(schema=SCHEMA, index_batch=BATCH) async def test_delete_skillset(self, api_key, endpoint, index_name, **kwargs): diff --git a/sdk/search/azure-search-documents/tests/recordings/test_search_index_client_skillset_live.test_create_skillset.yaml b/sdk/search/azure-search-documents/tests/recordings/test_search_index_client_skillset_live.test_create_skillset.yaml index 0e61e15a6ac6..9e9d0439ce64 100644 --- a/sdk/search/azure-search-documents/tests/recordings/test_search_index_client_skillset_live.test_create_skillset.yaml +++ b/sdk/search/azure-search-documents/tests/recordings/test_search_index_client_skillset_live.test_create_skillset.yaml @@ -1,19 +1,21 @@ interactions: - request: body: '{"name": "test-ss", "description": "desc", "skills": [{"@odata.type": "#Microsoft.Skills.Text.EntityRecognitionSkill", - "description": "Skill Version 1", "inputs": [{"name": "text", "source": "/document/content"}], - "outputs": [{"name": "organizations", "targetName": "organizationsS1"}], "includeTypelessEntities": - true}, {"@odata.type": "#Microsoft.Skills.Text.V3.EntityRecognitionSkill", "description": - "Skill Version 3", "inputs": [{"name": "text", "source": "/document/content"}], - "outputs": [{"name": "organizations", "targetName": "organizationsS2"}], "modelVersion": - "3"}, {"@odata.type": "#Microsoft.Skills.Text.SentimentSkill", "description": - "Sentiment V1", "inputs": [{"name": "text", "source": "/document/content"}], - "outputs": [{"name": "score", "targetName": "scoreS3"}]}, {"@odata.type": "#Microsoft.Skills.Text.V3.SentimentSkill", - "description": "Sentiment V3", "inputs": [{"name": "text", "source": "/document/content"}], - "outputs": [{"name": "confidenceScores", "targetName": "scoreS4"}], "includeOpinionMining": - true}, {"@odata.type": "#Microsoft.Skills.Text.V3.EntityLinkingSkill", "inputs": - [{"name": "text", "source": "/document/content"}], "outputs": [{"name": "entities", - "targetName": "entitiesS5"}], "minimumPrecision": 0.5}]}' + "name": "skill1", "description": "Skill Version 1", "inputs": [{"name": "text", + "source": "/document/content"}], "outputs": [{"name": "organizations", "targetName": + "organizationsS1"}], "includeTypelessEntities": true}, {"@odata.type": "#Microsoft.Skills.Text.V3.EntityRecognitionSkill", + "name": "skill2", "description": "Skill Version 3", "inputs": [{"name": "text", + "source": "/document/content"}], "outputs": [{"name": "organizations", "targetName": + "organizationsS2"}], "modelVersion": "3"}, {"@odata.type": "#Microsoft.Skills.Text.SentimentSkill", + "name": "skill3", "description": "Sentiment V1", "inputs": [{"name": "text", + "source": "/document/content"}], "outputs": [{"name": "score", "targetName": + "scoreS3"}]}, {"@odata.type": "#Microsoft.Skills.Text.V3.SentimentSkill", "name": + "skill4", "description": "Sentiment V3", "inputs": [{"name": "text", "source": + "/document/content"}], "outputs": [{"name": "confidenceScores", "targetName": + "scoreS4"}], "includeOpinionMining": true}, {"@odata.type": "#Microsoft.Skills.Text.V3.EntityLinkingSkill", + "name": "skill5", "inputs": [{"name": "text", "source": "/document/content"}], + "outputs": [{"name": "entities", "targetName": "entitiesS5"}], "minimumPrecision": + 0.5}]}' headers: Accept: - application/json;odata.metadata=minimal @@ -22,33 +24,33 @@ interactions: Connection: - keep-alive Content-Length: - - '1251' + - '1341' Content-Type: - application/json User-Agent: - - azsdk-python-search-documents/11.3.0b4 Python/3.9.2 (Windows-10-10.0.19041-SP0) + - azsdk-python-search-documents/11.3.0b5 Python/3.9.2 (Windows-10-10.0.19041-SP0) method: POST uri: https://searchd998184f.search.windows.net/skillsets?api-version=2021-04-30-Preview response: body: - string: '{"@odata.context":"https://searchd998184f.search.windows.net/$metadata#skillsets/$entity","@odata.etag":"\"0x8D977C13CD227F9\"","name":"test-ss","description":"desc","skills":[{"@odata.type":"#Microsoft.Skills.Text.EntityRecognitionSkill","name":null,"description":"Skill - Version 1","context":null,"categories":[],"defaultLanguageCode":null,"minimumPrecision":null,"includeTypelessEntities":true,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"organizations","targetName":"organizationsS1"}]},{"@odata.type":"#Microsoft.Skills.Text.V3.EntityRecognitionSkill","name":null,"description":"Skill - Version 3","context":null,"categories":[],"defaultLanguageCode":null,"minimumPrecision":null,"modelVersion":"3","inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"organizations","targetName":"organizationsS2"}]},{"@odata.type":"#Microsoft.Skills.Text.SentimentSkill","name":null,"description":"Sentiment - V1","context":null,"defaultLanguageCode":null,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"score","targetName":"scoreS3"}]},{"@odata.type":"#Microsoft.Skills.Text.V3.SentimentSkill","name":null,"description":"Sentiment - V3","context":null,"defaultLanguageCode":null,"modelVersion":null,"includeOpinionMining":true,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"confidenceScores","targetName":"scoreS4"}]},{"@odata.type":"#Microsoft.Skills.Text.V3.EntityLinkingSkill","name":null,"description":null,"context":null,"defaultLanguageCode":null,"minimumPrecision":0.5,"modelVersion":null,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"entities","targetName":"entitiesS5"}]}],"cognitiveServices":null,"knowledgeStore":null,"encryptionKey":null}' + string: '{"@odata.context":"https://searchd998184f.search.windows.net/$metadata#skillsets/$entity","@odata.etag":"\"0x8D99B03895900E6\"","name":"test-ss","description":"desc","skills":[{"@odata.type":"#Microsoft.Skills.Text.EntityRecognitionSkill","name":"skill1","description":"Skill + Version 1","context":null,"categories":[],"defaultLanguageCode":null,"minimumPrecision":null,"includeTypelessEntities":true,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"organizations","targetName":"organizationsS1"}]},{"@odata.type":"#Microsoft.Skills.Text.V3.EntityRecognitionSkill","name":"skill2","description":"Skill + Version 3","context":null,"categories":[],"defaultLanguageCode":null,"minimumPrecision":null,"modelVersion":"3","inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"organizations","targetName":"organizationsS2"}]},{"@odata.type":"#Microsoft.Skills.Text.SentimentSkill","name":"skill3","description":"Sentiment + V1","context":null,"defaultLanguageCode":null,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"score","targetName":"scoreS3"}]},{"@odata.type":"#Microsoft.Skills.Text.V3.SentimentSkill","name":"skill4","description":"Sentiment + V3","context":null,"defaultLanguageCode":null,"modelVersion":null,"includeOpinionMining":true,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"confidenceScores","targetName":"scoreS4"}]},{"@odata.type":"#Microsoft.Skills.Text.V3.EntityLinkingSkill","name":"skill5","description":null,"context":null,"defaultLanguageCode":null,"minimumPrecision":0.5,"modelVersion":null,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"entities","targetName":"entitiesS5"}]}],"cognitiveServices":null,"knowledgeStore":null,"encryptionKey":null}' headers: cache-control: - no-cache content-length: - - '1940' + - '1960' content-type: - application/json; odata.metadata=minimal date: - - Tue, 14 Sep 2021 20:50:08 GMT + - Fri, 29 Oct 2021 17:42:54 GMT elapsed-time: - - '2192' + - '2093' etag: - - W/"0x8D977C13CD227F9" + - W/"0x8D99B03895900E6" expires: - '-1' location: @@ -60,7 +62,7 @@ interactions: preference-applied: - odata.include-annotations="*" request-id: - - 5895d1df-159d-11ec-ab13-74c63bed1137 + - a4e19c2b-38df-11ec-9ba5-74c63bed1137 strict-transport-security: - max-age=15724800; includeSubDomains status: @@ -76,28 +78,27 @@ interactions: Connection: - keep-alive User-Agent: - - azsdk-python-search-documents/11.3.0b4 Python/3.9.2 (Windows-10-10.0.19041-SP0) + - azsdk-python-search-documents/11.3.0b5 Python/3.9.2 (Windows-10-10.0.19041-SP0) method: GET uri: https://searchd998184f.search.windows.net/skillsets?api-version=2021-04-30-Preview response: body: - string: '{"@odata.context":"https://searchd998184f.search.windows.net/$metadata#skillsets","value":[{"@odata.etag":"\"0x8D977C13CD227F9\"","name":"test-ss","description":"desc","skills":[{"@odata.type":"#Microsoft.Skills.Text.EntityRecognitionSkill","name":"#1","description":"Skill - Version 1","context":"/document","categories":["Person","Quantity","Organization","URL","Email","Location","DateTime"],"defaultLanguageCode":"en","minimumPrecision":null,"includeTypelessEntities":true,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"organizations","targetName":"organizationsS1"}]},{"@odata.type":"#Microsoft.Skills.Text.V3.EntityRecognitionSkill","name":"#2","description":"Skill - Version 3","context":"/document","categories":["Product","Phone Number","Person","Quantity","IP - Address","Organization","URL","Email","Event","Skill","Location","PersonType","Address","DateTime"],"defaultLanguageCode":"en","minimumPrecision":null,"modelVersion":"3","inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"organizations","targetName":"organizationsS2"}]},{"@odata.type":"#Microsoft.Skills.Text.SentimentSkill","name":"#3","description":"Sentiment - V1","context":"/document","defaultLanguageCode":"en","inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"score","targetName":"scoreS3"}]},{"@odata.type":"#Microsoft.Skills.Text.V3.SentimentSkill","name":"#4","description":"Sentiment - V3","context":"/document","defaultLanguageCode":"en","modelVersion":null,"includeOpinionMining":true,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"confidenceScores","targetName":"scoreS4"}]},{"@odata.type":"#Microsoft.Skills.Text.V3.EntityLinkingSkill","name":"#5","description":null,"context":"/document","defaultLanguageCode":"en","minimumPrecision":0.5,"modelVersion":null,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"entities","targetName":"entitiesS5"}]}],"cognitiveServices":null,"knowledgeStore":null,"encryptionKey":null}]}' + string: '{"@odata.context":"https://searchd998184f.search.windows.net/$metadata#skillsets","value":[{"@odata.etag":"\"0x8D99B03895900E6\"","name":"test-ss","description":"desc","skills":[{"@odata.type":"#Microsoft.Skills.Text.EntityRecognitionSkill","name":"skill1","description":"Skill + Version 1","context":"/document","categories":["Person","Quantity","Organization","URL","Email","Location","DateTime"],"defaultLanguageCode":"en","minimumPrecision":null,"includeTypelessEntities":true,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"organizations","targetName":"organizationsS1"}]},{"@odata.type":"#Microsoft.Skills.Text.V3.EntityRecognitionSkill","name":"skill2","description":"Skill + Version 3","context":"/document","categories":["Product","PhoneNumber","Person","Quantity","Organization","IPAddress","URL","Email","Event","Skill","Location","PersonType","Address","DateTime"],"defaultLanguageCode":"en","minimumPrecision":null,"modelVersion":"3","inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"organizations","targetName":"organizationsS2"}]},{"@odata.type":"#Microsoft.Skills.Text.SentimentSkill","name":"skill3","description":"Sentiment + V1","context":"/document","defaultLanguageCode":"en","inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"score","targetName":"scoreS3"}]},{"@odata.type":"#Microsoft.Skills.Text.V3.SentimentSkill","name":"skill4","description":"Sentiment + V3","context":"/document","defaultLanguageCode":"en","modelVersion":null,"includeOpinionMining":true,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"confidenceScores","targetName":"scoreS4"}]},{"@odata.type":"#Microsoft.Skills.Text.V3.EntityLinkingSkill","name":"skill5","description":null,"context":"/document","defaultLanguageCode":"en","minimumPrecision":0.5,"modelVersion":null,"inputs":[{"name":"text","source":"/document/content","sourceContext":null,"inputs":[]}],"outputs":[{"name":"entities","targetName":"entitiesS5"}]}],"cognitiveServices":null,"knowledgeStore":null,"encryptionKey":null}]}' headers: cache-control: - no-cache content-length: - - '2196' + - '2214' content-type: - application/json; odata.metadata=minimal date: - - Tue, 14 Sep 2021 20:50:08 GMT + - Fri, 29 Oct 2021 17:42:54 GMT elapsed-time: - - '118' + - '100' expires: - '-1' odata-version: @@ -107,7 +108,7 @@ interactions: preference-applied: - odata.include-annotations="*" request-id: - - 59ff6a42-159d-11ec-b22c-74c63bed1137 + - a65031ef-38df-11ec-ab76-74c63bed1137 strict-transport-security: - max-age=15724800; includeSubDomains vary: @@ -115,4 +116,42 @@ interactions: status: code: 200 message: OK +- request: + body: '{"skillNames": ["skill1", "skill2", "skill3", "skill4", "skill5"]}' + headers: + Accept: + - application/json;odata.metadata=minimal + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '66' + Content-Type: + - application/json + User-Agent: + - azsdk-python-search-documents/11.3.0b5 Python/3.9.2 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://searchd998184f.search.windows.net/skillsets('test-ss')/search.resetskills?api-version=2021-04-30-Preview + response: + body: + string: '' + headers: + cache-control: + - no-cache + date: + - Fri, 29 Oct 2021 17:42:54 GMT + elapsed-time: + - '47' + expires: + - '-1' + pragma: + - no-cache + request-id: + - a66c4a6c-38df-11ec-ae2d-74c63bed1137 + strict-transport-security: + - max-age=15724800; includeSubDomains + status: + code: 204 + message: No Content version: 1 diff --git a/sdk/search/azure-search-documents/tests/test_search_index_client_skillset_live.py b/sdk/search/azure-search-documents/tests/test_search_index_client_skillset_live.py index b0fc016d2633..a2eda6d5f787 100644 --- a/sdk/search/azure-search-documents/tests/test_search_index_client_skillset_live.py +++ b/sdk/search/azure-search-documents/tests/test_search_index_client_skillset_live.py @@ -44,28 +44,33 @@ def test_create_skillset(self, api_key, endpoint, index_name, **kwargs): client = SearchIndexerClient(endpoint, AzureKeyCredential(api_key)) name = "test-ss" - s1 = EntityRecognitionSkill(inputs=[InputFieldMappingEntry(name="text", source="/document/content")], + s1 = EntityRecognitionSkill(name="skill1", + inputs=[InputFieldMappingEntry(name="text", source="/document/content")], outputs=[OutputFieldMappingEntry(name="organizations", target_name="organizationsS1")], description="Skill Version 1", include_typeless_entities=True) - s2 = EntityRecognitionSkill(inputs=[InputFieldMappingEntry(name="text", source="/document/content")], + s2 = EntityRecognitionSkill(name="skill2", + inputs=[InputFieldMappingEntry(name="text", source="/document/content")], outputs=[OutputFieldMappingEntry(name="organizations", target_name="organizationsS2")], skill_version=EntityRecognitionSkillVersion.LATEST, description="Skill Version 3", model_version="3") - s3 = SentimentSkill(inputs=[InputFieldMappingEntry(name="text", source="/document/content")], + s3 = SentimentSkill(name="skill3", + inputs=[InputFieldMappingEntry(name="text", source="/document/content")], outputs=[OutputFieldMappingEntry(name="score", target_name="scoreS3")], skill_version=SentimentSkillVersion.V1, description="Sentiment V1") - s4 = SentimentSkill(inputs=[InputFieldMappingEntry(name="text", source="/document/content")], + s4 = SentimentSkill(name="skill4", + inputs=[InputFieldMappingEntry(name="text", source="/document/content")], outputs=[OutputFieldMappingEntry(name="confidenceScores", target_name="scoreS4")], skill_version=SentimentSkillVersion.V3, description="Sentiment V3", include_opinion_mining=True) - s5 = EntityLinkingSkill(inputs=[InputFieldMappingEntry(name="text", source="/document/content")], + s5 = EntityLinkingSkill(name="skill5", + inputs=[InputFieldMappingEntry(name="text", source="/document/content")], outputs=[OutputFieldMappingEntry(name="entities", target_name="entitiesS5")], minimum_precision=0.5) @@ -94,6 +99,8 @@ def test_create_skillset(self, api_key, endpoint, index_name, **kwargs): assert len(client.get_skillsets()) == 1 + client.reset_skills(result, [x.name for x in result.skills]) + def test_create_skillset_validation(self, **kwargs): with pytest.raises(ValueError) as err: