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

fix sample and readme issues #12595

Merged
merged 1 commit into from
Jul 17, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 7 additions & 5 deletions sdk/search/azure-search-documents/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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():
Expand Down