Skip to content

Commit cc9f6e7

Browse files
committed
GH issue resolution
1 parent c603c60 commit cc9f6e7

File tree

1 file changed

+31
-17
lines changed

1 file changed

+31
-17
lines changed

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

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ title: 'Quickstart: Create a search index in Python using REST APIs'
33
titleSuffix: Azure Cognitive Search
44
description: Explains how to create an index, load data, and run queries using Python, Jupyter Notebooks, and the Azure Cognitive Search REST API.
55

6-
author: tchristiani
6+
author: HeidiSteen
77
manager: nitinme
8-
ms.author: terrychr
8+
ms.author: heidist
99
ms.service: cognitive-search
1010
ms.topic: quickstart
1111
ms.devlang: rest-api
12-
ms.date: 02/10/2020
12+
ms.date: 04/01/2020
1313
---
1414

1515
# Quickstart: Create an Azure Cognitive Search index in Python using Jupyter notebooks
@@ -193,7 +193,7 @@ To push documents, use an HTTP POST request to your index's URL endpoint. The RE
193193
"@search.action": "upload",
194194
"HotelId": "3",
195195
"HotelName": "Triple Landscape Hotel",
196-
"Description": "The Hotel stands out for its gastronomic excellence under the management of William Dough, who advises on and oversees all of the Hotels restaurant services.",
196+
"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.",
197197
"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.",
198198
"Category": "Resort and Spa",
199199
"Tags": [ "air conditioning", "bar", "continental breakfast" ],
@@ -252,45 +252,59 @@ This step shows you how to query an index using the [Search Documents REST API](
252252

253253
```python
254254
searchstring = '&search=*&$count=true'
255+
256+
url = endpoint + "indexes/hotels-quickstart/docs" + api_version + searchstring
257+
response = requests.get(url, headers=headers, json=searchstring)
258+
query = response.json()
259+
pprint(query)
255260
```
256261

257262
1. In a new cell, provide the following example to search on the terms "hotels" and "wifi". Add $select to specify which fields to include in the search results.
258263

259264
```python
260265
searchstring = '&search=hotels wifi&$count=true&$select=HotelId,HotelName'
261-
```
262266

263-
1. 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.
264-
265-
```python
266267
url = endpoint + "indexes/hotels-quickstart/docs" + api_version + searchstring
267268
response = requests.get(url, headers=headers, json=searchstring)
268269
query = response.json()
269-
pprint(query)
270+
pprint(query)
270271
```
271272

272-
1. Run each step. Results should look similar to the following output.
273+
Results should look similar to the following output.
273274

274275
![Search an index](media/search-get-started-python/search-index.png "Search an index")
275276

276-
1. Try a few other query examples to get a feel for the syntax. You can replace the `searchstring` with the following examples and then rerun the search request.
277-
278-
Apply a filter:
277+
1. Next, apply a $filter expression that selects only those hotels with a rating greater than 4.
279278

280279
```python
281280
searchstring = '&search=*&$filter=Rating gt 4&$select=HotelId,HotelName,Description,Rating'
281+
282+
url = endpoint + "indexes/hotels-quickstart/docs" + api_version + searchstring
283+
response = requests.get(url, headers=headers, json=searchstring)
284+
query = response.json()
285+
pprint(query)
282286
```
283287

284-
Take the top two results:
288+
1. By default, the search engine returns the top 50 documents but you can use top and skip to add pagination and choose how many documents in each result. This query returns two documents in each result set.
285289

286290
```python
287-
searchstring = '&search=boutique&$top=2&$select=HotelId,HotelName,Description,Category'
291+
searchstring = '&search=boutique&$top=2&$select=HotelId,HotelName,Description'
292+
293+
url = endpoint + "indexes/hotels-quickstart/docs" + api_version + searchstring
294+
response = requests.get(url, headers=headers, json=searchstring)
295+
query = response.json()
296+
pprint(query)
288297
```
289298

290-
Order by a specific field:
299+
1. In this last example, use $orderby to sort results by city. This example includes fields from the Address collection.
291300

292301
```python
293-
searchstring = '&search=pool&$orderby=Address/City&$select=HotelId, HotelName, Address/City, Address/StateProvince, Tags'
302+
searchstring = '&search=pool&$orderby=Address/City&$select=HotelId, HotelName, Address/City, Address/StateProvince'
303+
304+
url = endpoint + "indexes/hotels-quickstart/docs" + api_version + searchstring
305+
response = requests.get(url, headers=headers, json=searchstring)
306+
query = response.json()
307+
pprint(query)
294308
```
295309

296310
## Clean up

0 commit comments

Comments
 (0)