Skip to content

Commit abb34c1

Browse files
committed
Update quickstarts to use approved hotels dataset
1 parent f77056b commit abb34c1

File tree

3 files changed

+158
-72
lines changed

3 files changed

+158
-72
lines changed

Quickstart-Semantic-Search/semantic-search-quickstart.ipynb

Lines changed: 139 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@
2525
},
2626
{
2727
"cell_type": "code",
28-
"execution_count": null,
28+
"execution_count": 2,
2929
"metadata": {},
3030
"outputs": [],
3131
"source": [
32-
"! pip install azure-search-documents==11.6.0b1 --quiet\n",
32+
"! pip install azure-search-documents==11.6.0b12 --quiet\n",
3333
"! pip install azure-identity --quiet\n",
3434
"! pip install python-dotenv --quiet"
3535
]
@@ -56,9 +56,17 @@
5656
},
5757
{
5858
"cell_type": "code",
59-
"execution_count": null,
59+
"execution_count": 6,
6060
"metadata": {},
61-
"outputs": [],
61+
"outputs": [
62+
{
63+
"name": "stdout",
64+
"output_type": "stream",
65+
"text": [
66+
" hotels-quickstart-py created\n"
67+
]
68+
}
69+
],
6270
"source": [
6371
"from azure.core.credentials import AzureKeyCredential\n",
6472
"\n",
@@ -85,7 +93,6 @@
8593
" SimpleField(name=\"HotelId\", type=SearchFieldDataType.String, key=True),\n",
8694
" SearchableField(name=\"HotelName\", type=SearchFieldDataType.String, sortable=True),\n",
8795
" SearchableField(name=\"Description\", type=SearchFieldDataType.String, analyzer_name=\"en.lucene\"),\n",
88-
" SearchableField(name=\"Description_fr\", type=SearchFieldDataType.String, analyzer_name=\"fr.lucene\"),\n",
8996
" SearchableField(name=\"Category\", type=SearchFieldDataType.String, facetable=True, filterable=True, sortable=True),\n",
9097
"\n",
9198
" SearchableField(name=\"Tags\", collection=True, type=SearchFieldDataType.String, facetable=True, filterable=True),\n",
@@ -104,7 +111,7 @@
104111
" ]\n",
105112
"\n",
106113
"semantic_config = SemanticConfiguration(\n",
107-
" name=\"my-semantic-config\",\n",
114+
" name=\"semantic-config\",\n",
108115
" prioritized_fields=SemanticPrioritizedFields(\n",
109116
" title_field=SemanticField(field_name=\"HotelName\"),\n",
110117
" keywords_fields=[SemanticField(field_name=\"Category\")],\n",
@@ -135,7 +142,7 @@
135142
},
136143
{
137144
"cell_type": "code",
138-
"execution_count": null,
145+
"execution_count": 7,
139146
"metadata": {},
140147
"outputs": [],
141148
"source": [
@@ -144,13 +151,12 @@
144151
" {\n",
145152
" \"@search.action\": \"upload\",\n",
146153
" \"HotelId\": \"1\",\n",
147-
" \"HotelName\": \"Secret Point Motel\",\n",
148-
" \"Description\": \"The hotel is ideally located on the main commercial artery of the city in the heart of New York. A few minutes away is Time's Square and the historic centre of the city, as well as other places of interest that make New York one of America's most attractive and cosmopolitan cities.\",\n",
149-
" \"Description_fr\": \"L'hôtel est idéalement situé sur la principale artère commerciale de la ville en plein cœur de New York. A quelques minutes se trouve la place du temps et le centre historique de la ville, ainsi que d'autres lieux d'intérêt qui font de New York l'une des villes les plus attractives et cosmopolites de l'Amérique.\",\n",
154+
" \"HotelName\": \"Stay-Kay City Hotel\",\n",
155+
" \"Description\": \"This classic hotel is fully-refurbished and ideally located on the main commercial artery of the city in the heart of New York. A few minutes away is Times Square and the historic centre of the city, as well as other places of interest that make New York one of America's most attractive and cosmopolitan cities.\",\n",
150156
" \"Category\": \"Boutique\",\n",
151-
" \"Tags\": [ \"pool\", \"air conditioning\", \"concierge\" ],\n",
157+
" \"Tags\": [ \"view\", \"air conditioning\", \"concierge\" ],\n",
152158
" \"ParkingIncluded\": \"false\",\n",
153-
" \"LastRenovationDate\": \"1970-01-18T00:00:00Z\",\n",
159+
" \"LastRenovationDate\": \"2020-01-18T00:00:00Z\",\n",
154160
" \"Rating\": 3.60,\n",
155161
" \"Address\": {\n",
156162
" \"StreetAddress\": \"677 5th Ave\",\n",
@@ -163,13 +169,12 @@
163169
" {\n",
164170
" \"@search.action\": \"upload\",\n",
165171
" \"HotelId\": \"2\",\n",
166-
" \"HotelName\": \"Twin Dome Motel\",\n",
167-
" \"Description\": \"The hotel is situated in a nineteenth century plaza, which has been expanded and renovated to the highest architectural standards to create a modern, functional and first-class hotel in which art and unique historical elements coexist with the most modern comforts.\",\n",
168-
" \"Description_fr\": \"L'hôtel est situé dans une place du XIXe siècle, qui a été agrandie et rénovée aux plus hautes normes architecturales pour créer un hôtel moderne, fonctionnel et de première classe dans lequel l'art et les éléments historiques uniques coexistent avec le confort le plus moderne.\",\n",
172+
" \"HotelName\": \"Old Century Hotel\",\n",
173+
" \"Description\": \"The hotel is situated in a nineteenth century plaza, which has been expanded and renovated to the highest architectural standards to create a modern, functional and first-class hotel in which art and unique historical elements coexist with the most modern comforts. The hotel also regularly hosts events like wine tastings, beer dinners, and live music.\",\n",
169174
" \"Category\": \"Boutique\",\n",
170175
" \"Tags\": [ \"pool\", \"free wifi\", \"concierge\" ],\n",
171176
" \"ParkingIncluded\": \"false\",\n",
172-
" \"LastRenovationDate\": \"1979-02-18T00:00:00Z\",\n",
177+
" \"LastRenovationDate\": \"2019-02-18T00:00:00Z\",\n",
173178
" \"Rating\": 3.60,\n",
174179
" \"Address\": {\n",
175180
" \"StreetAddress\": \"140 University Town Center Dr\",\n",
@@ -182,11 +187,10 @@
182187
" {\n",
183188
" \"@search.action\": \"upload\",\n",
184189
" \"HotelId\": \"3\",\n",
185-
" \"HotelName\": \"Triple Landscape Hotel\",\n",
186-
" \"Description\": \"The Hotel stands out for its gastronomic excellence under the management of William Dough, who advises on and oversees all of the Hotel's restaurant services.\",\n",
187-
" \"Description_fr\": \"L'hôtel est situé dans une place du XIXe siècle, qui a été agrandie et rénovée aux plus hautes normes architecturales pour créer un hôtel moderne, fonctionnel et de première classe dans lequel l'art et les éléments historiques uniques coexistent avec le confort le plus moderne.\",\n",
188-
" \"Category\": \"Resort and Spa\",\n",
189-
" \"Tags\": [ \"air conditioning\", \"bar\", \"continental breakfast\" ],\n",
190+
" \"HotelName\": \"Gastronomic Landscape Hotel\",\n",
191+
" \"Description\": \"The Gastronomic Hotel stands out for its culinary excellence under the management of William Dough, who advises on and oversees all of the Hotel’s restaurant services.\",\n",
192+
" \"Category\": \"Suite\",\n",
193+
" \"Tags\": [ \"restaurant\", \"bar\", \"continental breakfast\" ],\n",
190194
" \"ParkingIncluded\": \"true\",\n",
191195
" \"LastRenovationDate\": \"2015-09-20T00:00:00Z\",\n",
192196
" \"Rating\": 4.80,\n",
@@ -201,13 +205,12 @@
201205
" {\n",
202206
" \"@search.action\": \"upload\",\n",
203207
" \"HotelId\": \"4\",\n",
204-
" \"HotelName\": \"Sublime Cliff Hotel\",\n",
205-
" \"Description\": \"Sublime Cliff Hotel is located in the heart of the historic center of Sublime in an extremely vibrant and lively area within short walking distance to the sites and landmarks of the city and is surrounded by the extraordinary beauty of churches, buildings, shops and monuments. Sublime Cliff is part of a lovingly restored 1800 palace.\",\n",
206-
" \"Description_fr\": \"Le sublime Cliff Hotel est situé au coeur du centre historique de sublime dans un quartier extrêmement animé et vivant, à courte distance de marche des sites et monuments de la ville et est entouré par l'extraordinaire beauté des églises, des bâtiments, des commerces et Monuments. Sublime Cliff fait partie d'un Palace 1800 restauré avec amour.\",\n",
208+
" \"HotelName\": \"Sublime Palace Hotel\",\n",
209+
" \"Description\": \"Sublime Palace Hotel is located in the heart of the historic center of Sublime in an extremely vibrant and lively area within short walking distance to the sites and landmarks of the city and is surrounded by the extraordinary beauty of churches, buildings, shops and monuments. Sublime Cliff is part of a lovingly restored 19th century resort, updated for every modern convenience.\",\n",
207210
" \"Category\": \"Boutique\",\n",
208-
" \"Tags\": [ \"concierge\", \"view\", \"24-hour front desk service\" ],\n",
211+
" \"Tags\": [ \"concierge\", \"view\", \"air conditioning\" ],\n",
209212
" \"ParkingIncluded\": \"true\",\n",
210-
" \"LastRenovationDate\": \"1960-02-06T00:00:00Z\",\n",
213+
" \"LastRenovationDate\": \"2020-02-06T00:00:00Z\",\n",
211214
" \"Rating\": 4.60,\n",
212215
" \"Address\": {\n",
213216
" \"StreetAddress\": \"7400 San Pedro Ave\",\n",
@@ -230,9 +233,17 @@
230233
},
231234
{
232235
"cell_type": "code",
233-
"execution_count": null,
236+
"execution_count": 8,
234237
"metadata": {},
235-
"outputs": [],
238+
"outputs": [
239+
{
240+
"name": "stdout",
241+
"output_type": "stream",
242+
"text": [
243+
"Upload of new document succeeded: True\n"
244+
]
245+
}
246+
],
236247
"source": [
237248
"# Upload documents to the index\n",
238249
"search_client = SearchClient(endpoint=search_endpoint,\n",
@@ -259,9 +270,29 @@
259270
},
260271
{
261272
"cell_type": "code",
262-
"execution_count": null,
273+
"execution_count": 9,
263274
"metadata": {},
264-
"outputs": [],
275+
"outputs": [
276+
{
277+
"name": "stdout",
278+
"output_type": "stream",
279+
"text": [
280+
"Total Documents Matching Query: 4\n",
281+
"1.0\n",
282+
"Gastronomic Landscape Hotel\n",
283+
"Description: The Gastronomic Hotel stands out for its culinary excellence under the management of William Dough, who advises on and oversees all of the Hotel’s restaurant services.\n",
284+
"1.0\n",
285+
"Old Century Hotel\n",
286+
"Description: The hotel is situated in a nineteenth century plaza, which has been expanded and renovated to the highest architectural standards to create a modern, functional and first-class hotel in which art and unique historical elements coexist with the most modern comforts. The hotel also regularly hosts events like wine tastings, beer dinners, and live music.\n",
287+
"1.0\n",
288+
"Sublime Palace Hotel\n",
289+
"Description: Sublime Palace Hotel is located in the heart of the historic center of Sublime in an extremely vibrant and lively area within short walking distance to the sites and landmarks of the city and is surrounded by the extraordinary beauty of churches, buildings, shops and monuments. Sublime Cliff is part of a lovingly restored 19th century resort, updated for every modern convenience.\n",
290+
"1.0\n",
291+
"Stay-Kay City Hotel\n",
292+
"Description: This classic hotel is fully-refurbished and ideally located on the main commercial artery of the city in the heart of New York. A few minutes away is Times Square and the historic centre of the city, as well as other places of interest that make New York one of America's most attractive and cosmopolitan cities.\n"
293+
]
294+
}
295+
],
265296
"source": [
266297
"# Run an empty query (returns selected fields, all documents)\n",
267298
"results = search_client.search(query_type='simple',\n",
@@ -281,18 +312,33 @@
281312
"cell_type": "markdown",
282313
"metadata": {},
283314
"source": [
284-
"## Run a term query"
315+
"## Run a term query\n",
316+
"\n",
317+
"Other hotels in this small data set have a stronger signal for restaurant, but because \"site\" is a less frequent term, BM25 scores it higher."
285318
]
286319
},
287320
{
288321
"cell_type": "code",
289-
"execution_count": null,
322+
"execution_count": 14,
290323
"metadata": {},
291-
"outputs": [],
324+
"outputs": [
325+
{
326+
"name": "stdout",
327+
"output_type": "stream",
328+
"text": [
329+
"0.6791836\n",
330+
"Sublime Palace Hotel\n",
331+
"Description: Sublime Palace Hotel is located in the heart of the historic center of Sublime in an extremely vibrant and lively area within short walking distance to the sites and landmarks of the city and is surrounded by the extraordinary beauty of churches, buildings, shops and monuments. Sublime Cliff is part of a lovingly restored 19th century resort, updated for every modern convenience.\n",
332+
"0.5575875\n",
333+
"Gastronomic Landscape Hotel\n",
334+
"Description: The Gastronomic Hotel stands out for its culinary excellence under the management of William Dough, who advises on and oversees all of the Hotel’s restaurant services.\n"
335+
]
336+
}
337+
],
292338
"source": [
293339
"# Run a text query (returns a BM25-scored result set)\n",
294340
"results = search_client.search(query_type='simple',\n",
295-
" search_text=\"what hotel has a good restaurant on site\" ,\n",
341+
" search_text=\"restaurant on site\" ,\n",
296342
" select='HotelName,HotelId,Description',\n",
297343
" include_total_count=True)\n",
298344
" \n",
@@ -307,18 +353,37 @@
307353
"cell_type": "markdown",
308354
"metadata": {},
309355
"source": [
310-
"## Run a semantic query"
356+
"## Run a semantic query\n",
357+
"\n",
358+
"In contrast, the L2 ranker revisits the query and uses machine reading comprehension to promote results that are more meaningful to the query."
311359
]
312360
},
313361
{
314362
"cell_type": "code",
315-
"execution_count": null,
363+
"execution_count": 16,
316364
"metadata": {},
317-
"outputs": [],
365+
"outputs": [
366+
{
367+
"name": "stdout",
368+
"output_type": "stream",
369+
"text": [
370+
"2.132748603820801\n",
371+
"Gastronomic Landscape Hotel\n",
372+
"Description: The Gastronomic Hotel stands out for its culinary excellence under the management of William Dough, who advises on and oversees all of the Hotel’s restaurant services.\n",
373+
"Caption: The Gastronomic Hotel stands out for its culinary excellence under the management of William Dough, who advises on and oversees all of the Hotel’s<em> restaurant services.</em>\n",
374+
"\n",
375+
"1.6575827598571777\n",
376+
"Sublime Palace Hotel\n",
377+
"Description: Sublime Palace Hotel is located in the heart of the historic center of Sublime in an extremely vibrant and lively area within short walking distance to the sites and landmarks of the city and is surrounded by the extraordinary beauty of churches, buildings, shops and monuments. Sublime Cliff is part of a lovingly restored 19th century resort, updated for every modern convenience.\n",
378+
"Caption: Sublime Palace<em> Hotel </em>is located in the heart of the historic center of<em> Sublime </em>in an extremely vibrant and lively area within short walking distance to the sites and landmarks of the city and is surrounded by the extraordinary beauty of churches, buildings, shops and monuments. <em>Sublime Cliff </em>is part of a lovingly restored 19th century<em> resort,.</em>\n",
379+
"\n"
380+
]
381+
}
382+
],
318383
"source": [
319384
"# Runs a semantic query (runs a BM25-ranked query and promotes the most relevant matches to the top)\n",
320-
"results = search_client.search(query_type='semantic', semantic_configuration_name='my-semantic-config',\n",
321-
" search_text=\"what hotel has a good restaurant on site\", \n",
385+
"results = search_client.search(query_type='semantic', semantic_configuration_name='semantic-config',\n",
386+
" search_text=\"restaurant on site\", \n",
322387
" select='HotelName,Description,Category', query_caption='extractive')\n",
323388
"\n",
324389
"for result in results:\n",
@@ -344,12 +409,42 @@
344409
},
345410
{
346411
"cell_type": "code",
347-
"execution_count": null,
412+
"execution_count": 18,
348413
"metadata": {},
349-
"outputs": [],
414+
"outputs": [
415+
{
416+
"name": "stdout",
417+
"output_type": "stream",
418+
"text": [
419+
"Semantic Answer: The hotel is situated in<em> a nineteenth century plaza, </em>which has been expanded and renovated to the highest architectural standards to create a modern, functional and first-class hotel in which art and unique historical elements coexist with the most modern comforts. The hotel also regularly hosts events like wine tastings, beer dinners, and live ...\n",
420+
"Semantic Answer Score: 0.968999981880188\n",
421+
"\n",
422+
"2.4739253520965576\n",
423+
"Sublime Palace Hotel\n",
424+
"Description: Sublime Palace Hotel is located in the heart of the historic center of Sublime in an extremely vibrant and lively area within short walking distance to the sites and landmarks of the city and is surrounded by the extraordinary beauty of churches, buildings, shops and monuments. Sublime Cliff is part of a lovingly restored 19th century resort, updated for every modern convenience.\n",
425+
"Caption: <em>Sublime Palace Hotel </em>is located in the heart of the historic center of Sublime in an extremely vibrant and lively area within short walking distance to the sites and landmarks of the city and is surrounded by the extraordinary beauty of churches, buildings, shops and monuments. Sublime Cliff is part of a lovingly restored 19th century resort,.\n",
426+
"\n",
427+
"2.4739253520965576\n",
428+
"Old Century Hotel\n",
429+
"Description: The hotel is situated in a nineteenth century plaza, which has been expanded and renovated to the highest architectural standards to create a modern, functional and first-class hotel in which art and unique historical elements coexist with the most modern comforts. The hotel also regularly hosts events like wine tastings, beer dinners, and live music.\n",
430+
"Caption: The hotel is situated in<em> a nineteenth century plaza, </em>which has been expanded and renovated to the highest architectural standards to create a modern, functional and first-class hotel in which art and unique historical elements coexist with the most modern comforts. The hotel also regularly hosts events like wine tastings, beer dinners, and live.\n",
431+
"\n",
432+
"2.3384294509887695\n",
433+
"Stay-Kay City Hotel\n",
434+
"Description: This classic hotel is fully-refurbished and ideally located on the main commercial artery of the city in the heart of New York. A few minutes away is Times Square and the historic centre of the city, as well as other places of interest that make New York one of America's most attractive and cosmopolitan cities.\n",
435+
"Caption: This classic hotel is fully-refurbished and ideally located on the main commercial artery of the city in the heart of New York. A few minutes away is Times Square and the historic centre of the city, as well as other places of interest that make New York one of America's most attractive and cosmopolitan cities.\n",
436+
"\n",
437+
"1.7504537105560303\n",
438+
"Gastronomic Landscape Hotel\n",
439+
"Description: The Gastronomic Hotel stands out for its culinary excellence under the management of William Dough, who advises on and oversees all of the Hotel’s restaurant services.\n",
440+
"Caption: The<em> Gastronomic </em>Hotel stands out for its culinary excellence under the management of William Dough, who advises on and oversees all of the Hotel’s restaurant services.\n",
441+
"\n"
442+
]
443+
}
444+
],
350445
"source": [
351446
"# Run a semantic query that returns semantic answers \n",
352-
"results = search_client.search(query_type='semantic', semantic_configuration_name='my-semantic-config',\n",
447+
"results = search_client.search(query_type='semantic', semantic_configuration_name='semantic-config',\n",
353448
" search_text=\"what hotel is in a historic building\",\n",
354449
" select='HotelName,Description,Category', query_caption='extractive', query_answer=\"extractive\",)\n",
355450
"\n",
@@ -428,7 +523,7 @@
428523
],
429524
"metadata": {
430525
"kernelspec": {
431-
"display_name": "Python 3",
526+
"display_name": ".venv",
432527
"language": "python",
433528
"name": "python3"
434529
},
@@ -442,12 +537,7 @@
442537
"name": "python",
443538
"nbconvert_exporter": "python",
444539
"pygments_lexer": "ipython3",
445-
"version": "3.11.3"
446-
},
447-
"vscode": {
448-
"interpreter": {
449-
"hash": "9ff083f0c83558f9261023d47a77b9b3eb892c62cdbe066d046abcad1a5edb5c"
450-
}
540+
"version": "3.11.9"
451541
}
452542
},
453543
"nbformat": 4,

Quickstart/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ This sample is a Jupyter Python3 .ipynb file to perform the actions against the
4444

4545
## Next steps
4646

47-
You can learn more about Azure AI Search on the [official documentation site](https://docs.microsoft.com/azure/search).
47+
You can learn more about Azure AI Search on the [official documentation site](https://learn.microsoft.com/azure/search).

0 commit comments

Comments
 (0)