Skip to content

Commit f377d1c

Browse files
authored
add more content to index crud samples (#11443)
1 parent 93132ca commit f377d1c

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

sdk/search/azure-search-documents/samples/async_samples/sample_index_crud_operations_async.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
from azure.core.credentials import AzureKeyCredential
2929
from azure.search.documents.aio import SearchServiceClient
30-
from azure.search.documents import CorsOptions, Index, ScoringProfile, edm, SimpleField, SearchableField
30+
from azure.search.documents import ComplexField, CorsOptions, Index, ScoringProfile, edm, SimpleField, SearchableField
3131

3232
client = SearchServiceClient(service_endpoint, AzureKeyCredential(key)).get_indexes_client()
3333

@@ -36,7 +36,12 @@ async def create_index():
3636
name = "hotels"
3737
fields = [
3838
SimpleField(name="hotelId", type=edm.String, key=True),
39-
SimpleField(name="baseRate", type=edm.Double)
39+
SimpleField(name="baseRate", type=edm.Double),
40+
SearchableField(name="description", type=edm.String),
41+
ComplexField(name="address", fields=[
42+
SimpleField(name="streetAddress", type=edm.String),
43+
SimpleField(name="city", type=edm.String),
44+
])
4045
]
4146

4247
cors_options = CorsOptions(allowed_origins=["*"], max_age_in_seconds=60)
@@ -62,7 +67,13 @@ async def update_index():
6267
fields = fields = [
6368
SimpleField(name="hotelId", type=edm.String, key=True),
6469
SimpleField(name="baseRate", type=edm.Double),
65-
SearchableField(name="hotelName", type=edm.String)
70+
SearchableField(name="description", type=edm.String),
71+
SearchableField(name="hotelName", type=edm.String),
72+
ComplexField(name="address", fields=[
73+
SimpleField(name="streetAddress", type=edm.String),
74+
SimpleField(name="city", type=edm.String),
75+
SimpleField(name="state", type=edm.String),
76+
])
6677
]
6778

6879
cors_options = CorsOptions(allowed_origins=["*"], max_age_in_seconds=60)

sdk/search/azure-search-documents/samples/sample_index_crud_operations.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
key = os.getenv("AZURE_SEARCH_API_KEY")
2626

2727
from azure.core.credentials import AzureKeyCredential
28-
from azure.search.documents import SearchServiceClient, CorsOptions, Index, ScoringProfile, edm, SimpleField, SearchableField
28+
from azure.search.documents import ComplexField, SearchServiceClient, CorsOptions, Index, ScoringProfile, edm, SimpleField, SearchableField
2929

3030
client = SearchServiceClient(service_endpoint, AzureKeyCredential(key)).get_indexes_client()
3131

@@ -34,7 +34,12 @@ def create_index():
3434
name = "hotels"
3535
fields = [
3636
SimpleField(name="hotelId", type=edm.String, key=True),
37-
SimpleField(name="baseRate", type=edm.Double)
37+
SimpleField(name="baseRate", type=edm.Double),
38+
SearchableField(name="description", type=edm.String),
39+
ComplexField(name="address", fields=[
40+
SimpleField(name="streetAddress", type=edm.String),
41+
SimpleField(name="city", type=edm.String),
42+
])
3843
]
3944
cors_options = CorsOptions(allowed_origins=["*"], max_age_in_seconds=60)
4045
scoring_profiles = []
@@ -59,7 +64,13 @@ def update_index():
5964
fields = [
6065
SimpleField(name="hotelId", type=edm.String, key=True),
6166
SimpleField(name="baseRate", type=edm.Double),
62-
SearchableField(name="hotelName", type=edm.String)
67+
SearchableField(name="description", type=edm.String),
68+
SearchableField(name="hotelName", type=edm.String),
69+
ComplexField(name="address", fields=[
70+
SimpleField(name="streetAddress", type=edm.String),
71+
SimpleField(name="city", type=edm.String),
72+
SimpleField(name="state", type=edm.String),
73+
])
6374
]
6475
cors_options = CorsOptions(allowed_origins=["*"], max_age_in_seconds=60)
6576
scoring_profile = ScoringProfile(

0 commit comments

Comments
 (0)