Skip to content

Commit 00c04b4

Browse files
committed
Attempt to fix indentation
1 parent b6cd053 commit 00c04b4

File tree

1 file changed

+56
-57
lines changed

1 file changed

+56
-57
lines changed

articles/search/includes/quickstarts/search-get-started-vector-python.md

Lines changed: 56 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,23 @@ This quickstart uses `DefaultAzureCredential`, which simplifies authentication i
4343
git clone https://github.com/Azure-Samples/azure-search-python-samples
4444
```
4545

46-
This repo has Python code examples for several articles each in a separate subfolder.
46+
This repo has Python code examples for several articles each in a separate subfolder.
4747

4848
1. In Visual Studio Code, open the subfolder `Quickstart-Vector-Search`.
4949

50-
There are three files in this folder:
50+
There are three files in this folder:
5151

52-
- `vector-search-quickstart.ipynb`
53-
- `requirements.txt`
54-
- `sample.env`
52+
- `vector-search-quickstart.ipynb`
53+
- `requirements.txt`
54+
- `sample.env`
5555

5656
1. Rename the `sample.env` file to `.env` and modify the values in the `.env` file.
5757

5858
Use the search service URL as the `AZURE_SEARCH_ENDPOINT`. You can find the url in the [Azure portal](https://portal.azure.com). Go to your Azure AI Search service, on the **Overview** page, look for the URL field. An example endpoint might look like `https://mydemo.search.windows.net`.
5959

6060
Finally, choose a new `AZURE_SEARCH_INDEX_NAME` name, or use the one provided in the file.
6161

62-
1. In Visual Studio Code, work in an environment. On the **View** menu, select **Terminal...**, or select <kbd>Ctrl</kbd>+<kbd>`</kbd>.
62+
1. In Visual Studio Code, work in an environment. On the **View** menu, select **Terminal...**, or select Ctrl+`.
6363

6464
1. Run the following commands in the terminal:
6565

@@ -88,7 +88,7 @@ This quickstart uses `DefaultAzureCredential`, which simplifies authentication i
8888
> If this is the first time you have used a Jupyter Notebook (.ipynb) in Visual Studio Code, you will be prompted to install the Jupyter Notebook kernel and possibly other tools. Choose to install the suggested tools to continue with this quickstart.
8989
9090

91-
1. Find the cell below section titled "Install packages and set variables" and select the **Execute Cell (`Ctrl` + `Alt` + `Enter`)** button (which looks like a typical run button) to the left of the cell. Executing the cell loads the environment variables, creates the DefaultAzureCredential, and prints values to the output to confirm that the notebook's dependencies and `.env` are set up correctly.
91+
1. Find the cell below section titled "Install packages and set variables" and select the **Execute Cell (Ctrl+Alt+Enter)** button (which looks like a typical run button) to the left of the cell. Executing the cell loads the environment variables, creates the DefaultAzureCredential, and prints values to the output to confirm that the notebook's dependencies and `.env` are set up correctly.
9292

9393
```python
9494
# Load environment variables from .env file
@@ -226,7 +226,7 @@ The code in the `vector-search-quickstart.ipynb` uses several methods from the `
226226

227227
Key takeaways when creating vector index with the `azure.search.documents`:
228228

229-
- You define an index by creating a list of fields. Each field is created using a helper method that defines the field type and its settings.
229+
- You define an index by creating a list of fields. Each field is created using a helper method that defines the field type and its settings.
230230

231231
- This particular index supports multiple search capabilities, such as:
232232
- Full-text keyword search (`SearchableField(name="HotelName", ...)`, `SearchableField(name="Description", ...)`)
@@ -246,50 +246,50 @@ In Azure AI Search, the index stores all searchable content, while the search en
246246

247247
1. Find the cell below section titled "Create documents payload" and execute the cell. This cell contains the following code (truncated for brevity):
248248

249-
```python
250-
# Create a documents payload
251-
documents = [
252-
{
253-
"@search.action": "mergeOrUpload",
254-
"HotelId": "1",
255-
"HotelName": "Stay-Kay City Hotel",
256-
"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.",
257-
"DescriptionVector": [-0.048865054,-0.020307425,
258-
# <truncated>
259-
-0.018120624,-0.012772904],
260-
"Category": "Boutique",
261-
"Tags": [
262-
"view",
263-
"air conditioning",
264-
"concierge"
265-
],
266-
"ParkingIncluded": "false",
267-
"LastRenovationDate": "2022-01-18T00:00:00Z",
268-
"Rating": 3.60,
269-
"Address": {
270-
"StreetAddress": "677 5th Ave",
271-
"City": "New York",
272-
"StateProvince": "NY",
273-
"PostalCode": "10022",
274-
"Country": "USA"
275-
},
276-
"Location": {
277-
"type": "Point",
278-
"coordinates": [
279-
-73.975403,
280-
40.760586
281-
]
282-
}
283-
},
284-
# <truncated>
285-
]
249+
```python
250+
# Create a documents payload
251+
documents = [
252+
{
253+
"@search.action": "mergeOrUpload",
254+
"HotelId": "1",
255+
"HotelName": "Stay-Kay City Hotel",
256+
"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.",
257+
"DescriptionVector": [-0.048865054,-0.020307425,
258+
# <truncated>
259+
-0.018120624,-0.012772904],
260+
"Category": "Boutique",
261+
"Tags": [
262+
"view",
263+
"air conditioning",
264+
"concierge"
265+
],
266+
"ParkingIncluded": "false",
267+
"LastRenovationDate": "2022-01-18T00:00:00Z",
268+
"Rating": 3.60,
269+
"Address": {
270+
"StreetAddress": "677 5th Ave",
271+
"City": "New York",
272+
"StateProvince": "NY",
273+
"PostalCode": "10022",
274+
"Country": "USA"
275+
},
276+
"Location": {
277+
"type": "Point",
278+
"coordinates": [
279+
-73.975403,
280+
40.760586
281+
]
282+
}
283+
},
284+
# <truncated>
285+
]
286286
```
287-
287+
288288
This cell loads a variable named `documents` with a JSON object describing each document, along with the vectorized version of the article's description. This vector enables similarity search, where matching is based on meaning rather than exact keywords.
289-
289+
290290
> [!IMPORTANT]
291291
> The code in this example isn't runnable. Several characters or lines are removed for brevity. Instead, run the code in the Jupyter notebook.
292-
292+
293293
1. Find the cell below section titled "Upload the documents" and execute the cell. This cell contains the following code (truncated for brevity):
294294

295295
```python
@@ -360,7 +360,7 @@ The first example demonstrates a basic scenario where you want to find document
360360

361361
1. Find the cell below section titled "Single vector search" and execute the cell. This block contains the request to query the search index.
362362

363-
```python
363+
```python
364364
# IMPORTANT: Before you run this code, make sure the documents were successfully
365365
# created in the previous step. Sometimes it may take a few seconds for the index to be ready.
366366
# Check the "Document count" for the index in the Azure portal.
@@ -390,9 +390,8 @@ The first example demonstrates a basic scenario where you want to find document
390390
except Exception as ex:
391391
print("Vector search failed:", ex)
392392
else:
393-
print("No vector loaded, skipping search.")
394-
395-
```
393+
print("No vector loaded, skipping search.")
394+
```
396395

397396
This vector query is shortened for brevity. The `vectorQueries.vector` contains the vectorized text of the query input, `fields` determines which vector fields are searched, and `k` specifies the number of nearest neighbors to return.
398397

@@ -498,9 +497,9 @@ You can add filters, but the filters are applied to the nonvector content in you
498497
else:
499498
print("No vector loaded, skipping search.")
500499
```
501-
502-
The query was the same as the previous [single vector search example](#single-vector-search), but it includes a post-processing exclusion filter and returns only the two hotels within 300 kilometers.
503-
500+
501+
The query was the same as the previous [single vector search example](#single-vector-search), but it includes a post-processing exclusion filter and returns only the two hotels within 300 kilometers.
502+
504503
```output
505504
Total semantic hybrid results: 2
506505
- HotelId: 48
@@ -614,10 +613,10 @@ Hybrid search consists of keyword queries and vector queries in a single search
614613
"HotelName": "Luxury Lion Resort",
615614
"Description": "Unmatched Luxury. Visit our downtown hotel to indulge in luxury accommodations. Moments from the stadium, we feature the best in comfort"
616615
},
617-
```
616+
```
618617

619618
In the vector-only query, which uses HNSW for finding matches, the Sublime Palace Hotel drops to fourth position. Historic Lion, which was second in the full-text search and third in the vector search, doesn't experience the same range of fluctuation, so it appears as a top match in a homogenized result set.
620-
619+
621620
```json
622621
"value": [
623622
{

0 commit comments

Comments
 (0)