From d4359b37a5ef6a6a96092d1bb9f57a1d78227f2b Mon Sep 17 00:00:00 2001 From: Bryan Van de Ven Date: Thu, 14 May 2020 10:05:43 -0700 Subject: [PATCH] add more content to index crud samples --- .../sample_index_crud_operations_async.py | 17 ++++++++++++++--- .../samples/sample_index_crud_operations.py | 17 ++++++++++++++--- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/sdk/search/azure-search-documents/samples/async_samples/sample_index_crud_operations_async.py b/sdk/search/azure-search-documents/samples/async_samples/sample_index_crud_operations_async.py index 396b9cb0bf1a..e9228c8c448c 100644 --- a/sdk/search/azure-search-documents/samples/async_samples/sample_index_crud_operations_async.py +++ b/sdk/search/azure-search-documents/samples/async_samples/sample_index_crud_operations_async.py @@ -27,7 +27,7 @@ from azure.core.credentials import AzureKeyCredential from azure.search.documents.aio import SearchServiceClient -from azure.search.documents import CorsOptions, Index, ScoringProfile, edm, SimpleField, SearchableField +from azure.search.documents import ComplexField, CorsOptions, Index, ScoringProfile, edm, SimpleField, SearchableField client = SearchServiceClient(service_endpoint, AzureKeyCredential(key)).get_indexes_client() @@ -36,7 +36,12 @@ async def create_index(): name = "hotels" fields = [ SimpleField(name="hotelId", type=edm.String, key=True), - SimpleField(name="baseRate", type=edm.Double) + SimpleField(name="baseRate", type=edm.Double), + SearchableField(name="description", type=edm.String), + ComplexField(name="address", fields=[ + SimpleField(name="streetAddress", type=edm.String), + SimpleField(name="city", type=edm.String), + ]) ] cors_options = CorsOptions(allowed_origins=["*"], max_age_in_seconds=60) @@ -62,7 +67,13 @@ async def update_index(): fields = fields = [ SimpleField(name="hotelId", type=edm.String, key=True), SimpleField(name="baseRate", type=edm.Double), - SearchableField(name="hotelName", type=edm.String) + SearchableField(name="description", type=edm.String), + SearchableField(name="hotelName", type=edm.String), + ComplexField(name="address", fields=[ + SimpleField(name="streetAddress", type=edm.String), + SimpleField(name="city", type=edm.String), + SimpleField(name="state", type=edm.String), + ]) ] cors_options = CorsOptions(allowed_origins=["*"], max_age_in_seconds=60) diff --git a/sdk/search/azure-search-documents/samples/sample_index_crud_operations.py b/sdk/search/azure-search-documents/samples/sample_index_crud_operations.py index 6afe51d1a7c0..51c4cc1d2e5d 100644 --- a/sdk/search/azure-search-documents/samples/sample_index_crud_operations.py +++ b/sdk/search/azure-search-documents/samples/sample_index_crud_operations.py @@ -25,7 +25,7 @@ key = os.getenv("AZURE_SEARCH_API_KEY") from azure.core.credentials import AzureKeyCredential -from azure.search.documents import SearchServiceClient, CorsOptions, Index, ScoringProfile, edm, SimpleField, SearchableField +from azure.search.documents import ComplexField, SearchServiceClient, CorsOptions, Index, ScoringProfile, edm, SimpleField, SearchableField client = SearchServiceClient(service_endpoint, AzureKeyCredential(key)).get_indexes_client() @@ -34,7 +34,12 @@ def create_index(): name = "hotels" fields = [ SimpleField(name="hotelId", type=edm.String, key=True), - SimpleField(name="baseRate", type=edm.Double) + SimpleField(name="baseRate", type=edm.Double), + SearchableField(name="description", type=edm.String), + ComplexField(name="address", fields=[ + SimpleField(name="streetAddress", type=edm.String), + SimpleField(name="city", type=edm.String), + ]) ] cors_options = CorsOptions(allowed_origins=["*"], max_age_in_seconds=60) scoring_profiles = [] @@ -59,7 +64,13 @@ def update_index(): fields = [ SimpleField(name="hotelId", type=edm.String, key=True), SimpleField(name="baseRate", type=edm.Double), - SearchableField(name="hotelName", type=edm.String) + SearchableField(name="description", type=edm.String), + SearchableField(name="hotelName", type=edm.String), + ComplexField(name="address", fields=[ + SimpleField(name="streetAddress", type=edm.String), + SimpleField(name="city", type=edm.String), + SimpleField(name="state", type=edm.String), + ]) ] cors_options = CorsOptions(allowed_origins=["*"], max_age_in_seconds=60) scoring_profile = ScoringProfile(