diff --git a/sdk/search/azure-search-documents/README.md b/sdk/search/azure-search-documents/README.md index ebd9bbc64f6c..6bce89f6b26b 100644 --- a/sdk/search/azure-search-documents/README.md +++ b/sdk/search/azure-search-documents/README.md @@ -94,7 +94,7 @@ import os from azure.core.credentials import AzureKeyCredential from azure.search.documents import SearchClient -index_name = "nycjobs"; +index_name = "nycjobs" # Get the service endpoint and API key from the environment endpoint = os.environ["SEARCH_ENDPOINT"] key = os.environ["SEARCH_API_KEY"] @@ -293,12 +293,14 @@ key = os.environ["SEARCH_API_KEY"] DOCUMENT = { 'Category': 'Hotel', - 'HotelId': '1000', - 'Rating': 4.0, - 'Rooms': [], - 'HotelName': 'Azure Inn', + 'hotelId': '1000', + 'rating': 4.0, + 'rooms': [], + 'hotelName': 'Azure Inn', } +search_client = SearchClient(endpoint, index_name, AzureKeyCredential(key)) + result = client.upload_documents(documents=[DOCUMENT]) print("Upload of new document succeeded: {}".format(result[0].succeeded)) diff --git a/sdk/search/azure-search-documents/samples/async_samples/sample_indexers_operations_async.py b/sdk/search/azure-search-documents/samples/async_samples/sample_indexers_operations_async.py index ad3c028fd4fd..2f26c0a00b41 100644 --- a/sdk/search/azure-search-documents/samples/async_samples/sample_indexers_operations_async.py +++ b/sdk/search/azure-search-documents/samples/async_samples/sample_indexers_operations_async.py @@ -40,13 +40,13 @@ async def create_indexer(): # create an index - index_name = "hotels" + index_name = "indexer-hotels" fields = [ SimpleField(name="hotelId", type=SearchFieldDataType.String, key=True), SimpleField(name="baseRate", type=SearchFieldDataType.Double) ] index = SearchIndex(name=index_name, fields=fields) - ind_client = SearchIndexerClient(service_endpoint, AzureKeyCredential(key)) + ind_client = SearchIndexClient(service_endpoint, AzureKeyCredential(key)) async with ind_client: await ind_client.create_index(index) @@ -59,8 +59,8 @@ async def create_indexer(): connection_string=connection_string, container=container ) - async with ind_client: - data_source = await ind_client.create_data_source_connection(data_source_connection) + async with indexers_client: + data_source = await indexers_client.create_data_source_connection(data_source_connection) # create an indexer indexer = SearchIndexer( diff --git a/sdk/search/azure-search-documents/samples/sample_indexer_datasource_skillset.py b/sdk/search/azure-search-documents/samples/sample_indexer_datasource_skillset.py index f0684da68d6b..9b3dac6cccd4 100644 --- a/sdk/search/azure-search-documents/samples/sample_indexer_datasource_skillset.py +++ b/sdk/search/azure-search-documents/samples/sample_indexer_datasource_skillset.py @@ -38,7 +38,7 @@ from azure.search.documents.indexes.models import ( SearchIndexerDataContainer, SearchIndex, SearchIndexer, SimpleField, SearchFieldDataType, EntityRecognitionSkill, InputFieldMappingEntry, OutputFieldMappingEntry, SearchIndexerSkillset, - CorsOptions, IndexingSchedule, SearchableField, IndexingParameters + CorsOptions, IndexingSchedule, SearchableField, IndexingParameters, SearchIndexerDataSourceConnection ) from azure.search.documents.indexes import SearchIndexerClient, SearchIndexClient @@ -75,12 +75,13 @@ def _create_datasource(): # "searchcontainer" ds_client = SearchIndexerClient(service_endpoint, AzureKeyCredential(key)) container = SearchIndexerDataContainer(name='searchcontainer') - data_source = ds_client.create_datasource( + data_source_connection = SearchIndexerDataSourceConnection( name="hotel-datasource", type="azureblob", connection_string=connection_string, container=container ) + data_source = ds_client.create_data_source_connection(data_source_connection) return data_source def _create_skillset():