|
1 | 1 | { |
2 | 2 | "cells": [ |
3 | 3 | { |
| 4 | + "attachments": {}, |
4 | 5 | "cell_type": "markdown", |
5 | 6 | "metadata": {}, |
6 | 7 | "source": [ |
7 | | - "# Create a search index using the Azure Cognitive Search Python SDK" |
| 8 | + "# Create a search index in Azure Cognitive Search using the Azure SDK for Python" |
8 | 9 | ] |
9 | 10 | }, |
10 | 11 | { |
| 12 | + "attachments": {}, |
11 | 13 | "cell_type": "markdown", |
12 | 14 | "metadata": {}, |
13 | 15 | "source": [ |
14 | | - "This sample uses Jupyter Notebook to demonstrate index creation, data ingestion, and queries of an Azure Cognitive Search index by calling the azure-search-documents library in the Azure SDK for Python. This notebook is a companion document to this [Python quickstart](https://docs.microsoft.com/azure/search/search-get-started-python). \n", |
15 | | - "\n", |
16 | | - "To get started, load the libraries from the SDK. If you don't already have the SDK, uncomment the first install command and run that first." |
| 16 | + "This Jupyter Notebook steps through creating, loading, and querying an index in Azure Cognitive Search index by calling the azure-search-documents library in the Azure SDK for Python. " |
17 | 17 | ] |
18 | 18 | }, |
19 | 19 | { |
|
22 | 22 | "metadata": {}, |
23 | 23 | "outputs": [], |
24 | 24 | "source": [ |
25 | | - "# If you have not already installed the Python SDK, execute:\n", |
| 25 | + "# Uncomment the next line if you need to install the azure-search-documents client library:\n", |
26 | 26 | "# !pip install azure-search-documents --pre\n", |
27 | 27 | "\n", |
28 | | - "# This sample uses version: 11.1.0b3\n", |
| 28 | + "# This sample uses version: 11.1.0\n", |
29 | 29 | "!pip show azure-search-documents\n", |
30 | 30 | "\n", |
31 | 31 | "import os\n", |
|
44 | 44 | ] |
45 | 45 | }, |
46 | 46 | { |
| 47 | + "attachments": {}, |
47 | 48 | "cell_type": "markdown", |
48 | 49 | "metadata": {}, |
49 | 50 | "source": [ |
50 | | - "In the first cell, initialize the administrative and search query clients used to make each request. Replace the search service_name, admin_key and query_key with valid values. If you get ConnectionError \"Failed to establish a new connection\", verify that the api-key is a primary or secondary admin key, and not a query key." |
| 51 | + "In this step, initialize the search client used to make each request. Provide the name and admin API key of your search service. If you get ConnectionError \"Failed to establish a new connection\", verify that the api-key is a primary or secondary admin key, and not a query key." |
51 | 52 | ] |
52 | 53 | }, |
53 | 54 | { |
|
58 | 59 | "source": [ |
59 | 60 | "# Set the service endpoint and API key from the environment\n", |
60 | 61 | "\n", |
61 | | - "service_name = \"YOUR-SEARCH-SERIVCE-NAME\"\n", |
| 62 | + "service_name = \"YOUR-SEARCH-SERVICE-NAME\"\n", |
62 | 63 | "admin_key = \"YOUR-SEARCH-SERVICE-ADMIN-API-KEY\"\n", |
63 | 64 | "\n", |
64 | 65 | "index_name = \"hotels-quickstart\"\n", |
|
342 | 343 | "cell_type": "markdown", |
343 | 344 | "metadata": {}, |
344 | 345 | "source": [ |
345 | | - "In the next query, add search_fields (an array) to scope query matching to a single field. " |
| 346 | + "In the next query, add search_fields to scope query matching to a single field. If you're using a newer version of the client library, search_fields is an array. Add brackets around 'HotelName' if you get an error." |
346 | 347 | ] |
347 | 348 | }, |
348 | 349 | { |
|
351 | 352 | "metadata": {}, |
352 | 353 | "outputs": [], |
353 | 354 | "source": [ |
354 | | - "results = search_client.search(search_text=\"sublime\", search_fields=['HotelName'], select='HotelId,HotelName')\n", |
| 355 | + "results = search_client.search(search_text=\"sublime\", search_fields='HotelName', select='HotelId,HotelName')\n", |
355 | 356 | "\n", |
356 | 357 | "for result in results:\n", |
357 | 358 | " print(\"{}: {}\".format(result[\"HotelId\"], result[\"HotelName\"]))" |
|
479 | 480 | "name": "python", |
480 | 481 | "nbconvert_exporter": "python", |
481 | 482 | "pygments_lexer": "ipython3", |
482 | | - "version": "3.7.3" |
| 483 | + "version": "3.9.5" |
| 484 | + }, |
| 485 | + "vscode": { |
| 486 | + "interpreter": { |
| 487 | + "hash": "9ff083f0c83558f9261023d47a77b9b3eb892c62cdbe066d046abcad1a5edb5c" |
| 488 | + } |
483 | 489 | } |
484 | 490 | }, |
485 | 491 | "nbformat": 4, |
|
0 commit comments