Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -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()

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

Expand All @@ -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 = []
Expand All @@ -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(
Expand Down