Skip to content

Commit fba40bb

Browse files
authored
Merge pull request #79154 from HeidiSteen/heidist-python
Consistent index, documents, queries across all quickstarts
2 parents 29f52c4 + e83fcac commit fba40bb

File tree

5 files changed

+12
-13
lines changed

5 files changed

+12
-13
lines changed
-20.3 KB
Loading
20.5 KB
Loading
2.3 KB
Loading
2.32 KB
Loading

articles/search/search-get-started-python.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: 'Quickstart: Python and REST APIs - Azure Search'
33
description: Create, load, and query an index using Python, Jupyter Notebooks, and the Azure Search REST API.
44

5-
ms.date: 05/23/2019
5+
ms.date: 06/10/2019
66
author: heidisteen
77
manager: cgronlun
88
ms.author: heidist
@@ -83,22 +83,19 @@ In this task, start a Jupyter notebook and verify that you can connect to Azure
8383

8484
In contrast, an empty index collection returns this response: `{'@odata.context': 'https://mydemo.search.windows.net/$metadata#indexes(name)', 'value': []}`
8585

86-
> [!Tip]
87-
> On a free service, you are limited to three indexes, indexers, and data sources. This quickstart creates one of each. Make sure you have room to create new objects before going any further.
88-
8986
## 1 - Create an index
9087

9188
Unless you are using the portal, an index must exist on the service before you can load data. This step uses the [Create Index REST API](https://docs.microsoft.com/rest/api/searchservice/create-index) to push an index schema to the service.
9289

9390
Required elements of an index include a name, a fields collection, and a key. The fields collection defines the structure of a *document*. Each field has a name, type, and attributes that determine how the field is used (for example, whether it is 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.
9491

95-
This index is named "hotels-py" 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.
92+
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.
9693

9794
1. In the next cell, paste the following example into a cell to provide the schema.
9895

9996
```python
10097
index_schema = {
101-
"name": "hotels-py",
98+
"name": "hotels-quickstart",
10299
"fields": [
103100
{"name": "HotelId", "type": "Edm.String", "key": "true", "filterable": "true"},
104101
{"name": "HotelName", "type": "Edm.String", "searchable": "true", "filterable": "false", "sortable": "true", "facetable": "false"},
@@ -231,10 +228,10 @@ To push documents, use an HTTP POST request to your index's URL endpoint. The RE
231228
}
232229
```
233230

234-
2. In another cell, formulate the request. This POST request targets the docs collection of the hotels-py index and pushes the documents provided in the previous step.
231+
2. In another cell, formulate the request. This POST request targets the docs collection of the hotels-quickstart index and pushes the documents provided in the previous step.
235232

236233
```python
237-
url = endpoint + "indexes/hotels-py/docs/index" + api_version
234+
url = endpoint + "indexes/hotels-quickstart/docs/index" + api_version
238235
response = requests.post(url, headers=headers, json=documents)
239236
index_content = response.json()
240237
pprint(index_content)
@@ -255,10 +252,10 @@ This step shows you how to query an index using the [Search Documents REST API](
255252
searchstring = '&search=hotels wifi&$count=true&$select=HotelId,HotelName'
256253
```
257254

258-
2. In another cell, formulate a request. This GET request targets the docs collection of the hotels-py index, and attaches the query you specified in the previous step.
255+
2. In another cell, formulate a request. This GET request targets the docs collection of the hotels-quickstart index, and attaches the query you specified in the previous step.
259256

260257
```python
261-
url = endpoint + "indexes/hotels-py/docs" + api_version + searchstring
258+
url = endpoint + "indexes/hotels-quickstart/docs" + api_version + searchstring
262259
response = requests.get(url, headers=headers, json=searchstring)
263260
query = response.json()
264261
pprint(query)
@@ -290,14 +287,16 @@ This step shows you how to query an index using the [Search Documents REST API](
290287

291288
## Clean up
292289

293-
You should delete the index if you no longer need it. A free service is limited to three indexes. You might want to delete any indexes you are not actively using to make room for other tutorials.
290+
You should delete the index if you no longer need it. A free service is limited to three indexes. You should delete any indexes you are not actively using to make room for other tutorials.
291+
292+
The easiest way to delete objects is through the portal, but since this is a Python quickstart, the following syntax yields the same result:
294293

295294
```python
296-
url = endpoint + "indexes/hotels-py" + api_version
295+
url = endpoint + "indexes/hotels-quickstart" + api_version
297296
response = requests.delete(url, headers=headers)
298297
```
299298

300-
You can verify index deletion by returning a list of existing indexes. If hotels-py is gone, then you know your request succeeded.
299+
You can verify index deletion by requesting a list of existing indexes. If hotels-quickstart is gone, then you know your request succeeded.
301300

302301
```python
303302
url = endpoint + "indexes" + api_version + "&$select=name"

0 commit comments

Comments
 (0)