25
25
key = os .getenv ("AZURE_SEARCH_API_KEY" )
26
26
27
27
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
29
29
30
30
client = SearchServiceClient (service_endpoint , AzureKeyCredential (key )).get_indexes_client ()
31
31
@@ -34,7 +34,12 @@ def create_index():
34
34
name = "hotels"
35
35
fields = [
36
36
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
+ ])
38
43
]
39
44
cors_options = CorsOptions (allowed_origins = ["*" ], max_age_in_seconds = 60 )
40
45
scoring_profiles = []
@@ -59,7 +64,13 @@ def update_index():
59
64
fields = [
60
65
SimpleField (name = "hotelId" , type = edm .String , key = True ),
61
66
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
+ ])
63
74
]
64
75
cors_options = CorsOptions (allowed_origins = ["*" ], max_age_in_seconds = 60 )
65
76
scoring_profile = ScoringProfile (
0 commit comments