You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Build a Jupyter Notebook that creates, loads, and queries an Azure Cognitive Search index using Python and the [azure-search-documents library](/python/api/overview/azure/search-documents-readme) in the Azure SDK for Python. This article explains how to build a notebook step by step. Alternatively, you can [download and run a finished Jupyter Python notebook](https://github.com/Azure-Samples/azure-search-python-samples).
25
+
In this exercise, build a Jupyter Notebook that creates, loads, and queries an Azure Cognitive Search index using Python and the [azure-search-documents library](/python/api/overview/azure/search-documents-readme) in the Azure SDK for Python. This article explains how to build a notebook step by step. Alternatively, you can [download and run a finished Jupyter Python notebook](https://github.com/Azure-Samples/azure-search-python-samples).
26
26
27
27
If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) before you begin.
28
28
29
29
## Prerequisites
30
30
31
-
The following services and tools are required for this quickstart.
31
+
The following services and tools are used in this quickstart.
32
32
33
33
* Visual Studio Code with the Python extension (or equivalent tool), with Python 3.7 or later
34
34
@@ -38,24 +38,24 @@ The following services and tools are required for this quickstart.
38
38
39
39
## Copy a key and URL
40
40
41
-
REST calls require the service URL and an access key on every request. A search service is created with both, so if you added Azure Cognitive Search to your subscription, follow these steps to get the necessary information:
41
+
To connect to your search service, provide the endpoint and an access key. A search service is created with both, so if you added Azure Cognitive Search to your subscription, follow these steps to get the necessary information:
42
42
43
43
1.[Sign in to the Azure portal](https://portal.azure.com/), and in your search service **Overview** page, get the URL. An example endpoint might look like `https://mydemo.search.windows.net`.
44
44
45
45
1. In **Settings** > **Keys**, get an admin key for full rights on the service. There are two interchangeable admin keys, provided for business continuity in case you need to roll one over. You can use either the primary or secondary key on requests for adding, modifying, and deleting objects.
46
46
47
47

48
48
49
-
All requests require an api-key on every request sent to your service. Having a valid key establishes trust, on a per request basis, between the application sending the request and the service that handles it.
49
+
You'll provide these values in the next section when you set up the connection.
50
50
51
51
## Connect to Azure Cognitive Search
52
52
53
-
In this task, start Jupyter Notebook and verify that you can connect to Azure Cognitive Search. You'll do this step by requesting a list of indexes from your service.
53
+
In this task, create the notebook, load the libraries, and set up your clients.
54
54
55
55
1. Create a new Python3 notebook in Visual Studio Code:
56
56
57
57
1. Press F1 and search for "Python Select Interpreter" and choose a version of Python 3.7 or later.
58
-
1. Press F1 again and search for "Create: New Jupyter Notebook". You should have an empty, untitled .ipynb file open in the editor ready for the first entry.
58
+
1. Press F1 again and search for "Create: New Jupyter Notebook". You should have an empty, untitled `.ipynb` file open in the editor ready for the first entry.
59
59
60
60
1. In the first cell, load the libraries from the Azure SDK for Python, including [azure-search-documents](/python/api/azure-search-documents).
61
61
@@ -78,7 +78,7 @@ In this task, start Jupyter Notebook and verify that you can connect to Azure Co
78
78
)
79
79
```
80
80
81
-
1. Add a second cell and paste in the input the request elements that will be constants on every request. Provide your search service name, admin API key, and query API key, copied in a previous step. This cell also sets up the clients you'll use for specific operations: [SearchIndexClient](/python/api/azure-search-documents/azure.search.documents.indexes.searchindexclient) to create an index, and [SearchClient](/python/api/azure-search-documents/azure.search.documents.searchclient) to query an index.
81
+
1. Add a second cell and paste in the connection information. This cell also sets up the clients you'll use for specific operations: [SearchIndexClient](/python/api/azure-search-documents/azure.search.documents.indexes.searchindexclient) to create an index, and [SearchClient](/python/api/azure-search-documents/azure.search.documents.searchclient) to query an index.
82
82
83
83
```python
84
84
service_name ="YOUR-SEARCH-SERVICE-NAME"
@@ -111,9 +111,9 @@ In this task, start Jupyter Notebook and verify that you can connect to Azure Co
111
111
112
112
## 1 - Create an index
113
113
114
-
Required elements of an index include a name, a fields collection, and a key. The fields collection defines the structure of a logical *search document*, used for both loading data and returning results.
114
+
Required index elements include a name, a fields collection, and a document key that uniquely identifies each search document. The fields collection defines the structure of a logical *search document*, used for both loading data and returning results.
115
115
116
-
Each field has a name, type, and attributes that determine how the field is used (for example, whether it's full-text searchable, filterable, or retrievable in search results). Within an index, one of the fields of type `Edm.String` must be designated as the *key* for document identity.
116
+
Within the fields collection, each field has a name, type, and attributes that determine how the field is used (for example, whether it's full-text searchable, filterable, or retrievable in search results). Within an index, one of the fields of type `Edm.String` must be designated as the *key* for document identity.
117
117
118
118
This index is named "hotels-quickstart"and has the field definitions you see below. It's a subset of a larger [Hotels index](https://github.com/Azure-Samples/azure-search-sample-data/blob/master/hotels/Hotels_IndexDefinition.JSON) used in other walkthroughs. We trimmed it in this quickstart for brevity.
119
119
@@ -332,7 +332,7 @@ This step shows you how to query an index using the **search** method of the [se
332
332
print("Category: {}".format(result["Category"]))
333
333
```
334
334
335
-
1. In this example, we'll use the autocomplete function. Autocomplete is typically used in a search box to provide potential matches as the user types into the search box.
335
+
1. In the last example, we'll use the autocomplete function. Autocomplete is typically used in a search box to provide potential matches as the user types into the search box.
336
336
337
337
When the index was created, a suggester named `sg` was also created as part of the request. A suggester definition specifies which fields can be used to find potential matches to suggester requests. In this example, those fields are 'Tags', 'Address/City', 'Address/Country'. To simulate auto-complete, passin the letters "sa"as a partial string. The autocomplete method of [SearchClient](/python/api/azure-search-documents/azure.search.documents.searchclient) sends back potential term matches.
338
338
@@ -355,7 +355,7 @@ If you're using a free service, remember that you're limited to three indexes, i
355
355
356
356
## Next steps
357
357
358
-
In this JavaScript quickstart, you worked through a series of tasks to create an index, load it with documents, andrun queries. To continue learning, try the following tutorial.
358
+
In this Python quickstart, you worked through the fundamental workflow using the azure.search.documents library from the Python SDK. You performed tasks that created an index, loaded it with documents, andran queries. To continue learning, try the following tutorial.
359
359
360
360
> [!div class="nextstepaction"]
361
361
> [Tutorial: Add search to web apps](tutorial-python-overview.md)
0 commit comments