Skip to content

Commit b8f424e

Browse files
committed
moved sections
1 parent 00942dd commit b8f424e

File tree

4 files changed

+39
-116
lines changed

4 files changed

+39
-116
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ You can add filters, but the filters are applied to the nonvector content in you
458458
- HotelId: 2, HotelName: Old Century Hotel, Tags: ['pool', 'free wifi', 'air conditioning', 'concierge']
459459
```
460460

461-
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 three hotels that have free Wi-Fi.
461+
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 that have free Wi-Fi.
462462

463463
1. The next filter example uses a **geo filter**. Run the cell in the section titled "Vector query with a geo filter". This block contains the request to query the search index.
464464

articles/search/includes/quickstarts/semantic-ranker-csharp.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,13 @@ We recommend [Visual Studio](https://visualstudio.microsoft.com/vs/community/) f
7070

7171
In this section, you update a search index and send a query that invokes semantic ranking. Visual Studio Code displays the response after you run each cell. For more information about each step, see [Explaining the code](#explaining-the-code).
7272

73-
<!-- ```csharp
73+
### Add a semantic configuration to the hotels-sample-index
7474

75-
``` -->
75+
CODE GOES HERE
76+
77+
### Add semantic query parameters to a query
78+
79+
CODE GOES HERE
7680

7781
### Run the program
7882

@@ -84,8 +88,8 @@ Output includes messages from [Console.WriteLine](/dotnet/api/system.console.wri
8488

8589
Add `SemanticConfiguration` to a search index definition. If you're updating an existing index, this modification doesn't require a reindexing because the structure of your documents is unchanged.
8690

87-
+ [Update an index with a semantic configuration](#add-a-semantic-configuration-to-the-index)
88-
+ [Query the index using semantic parameters](#add-semantic-ranking-to-queries)
91+
+ [Update an index with a semantic configuration](#update-an-index-with-a-semantic-configuration)
92+
+ [Query the index using semantic parameters](#query-the-index-using-semantic-parameters)
8993

9094
### Update an index with a semantic configuration
9195

articles/search/includes/quickstarts/semantic-ranker-intro.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ms.topic: include
77
ms.date: 06/27/2025
88
---
99

10-
In this quickstart, you learn about the index and query modifications that invoke semantic ranker.
10+
In this quickstart, you learn about the index and query modifications that invoke semantic ranking.
1111

1212
In Azure AI Search, [semantic ranking](../../semantic-search-overview.md) is query-side functionality that uses machine reading comprehension from Microsoft to rescore search results, promoting the most semantically relevant matches to the top of the list. Depending on the content and the query, semantic ranking can [significantly improve search relevance](https://techcommunity.microsoft.com/t5/azure-ai-services-blog/azure-cognitive-search-outperforming-vector-search-with-hybrid/ba-p/3929167) with minimal developer effort. Semantic ranking is also required for [agentic retrieval (preview)](../../search-agentic-retrieval-concept.md).
1313

@@ -16,8 +16,8 @@ You can add a semantic configuration to an existing index with no rebuild requir
1616
In this quickstart:
1717

1818
> [!div class="checklist"]
19-
> - Add a semantic configuration to a search index
20-
> - Add semantic parameters to a query
19+
> + Add a semantic configuration to a search index
20+
> + Add semantic parameters to a query
2121
2222
## Prerequisites
2323

@@ -31,7 +31,7 @@ In this quickstart:
3131

3232
You can connect to your Azure AI Search service [using API keys](../../search-security-api-keys.md) or Microsoft Entra ID with role assignments. Keys are easier to start with, but roles are more secure.
3333

34-
To configure the recommended role-based access:
34+
To configure role-based access:
3535

3636
1. Sign in to the [Azure portal](https://portal.azure.com/) and select your search service.
3737

@@ -45,25 +45,25 @@ To configure the recommended role-based access:
4545

4646
1. Select **Add** > **Add role assignment**.
4747

48-
1. Assign the **Search Service Contributor** and **Search Index Data Contributor** roles to your user account.
48+
1. Assign these roles to your user account:
49+
50+
+ **Search Service Contributor**
51+
52+
+ **Search Index Data Contributor**
4953

5054
For more information, see [Connect to Azure AI Search using roles](../../search-security-rbac.md).
5155

5256
## Start with an index
5357

5458
This quickstart assumes an existing index, modified to include a semantic configuration. We recommend the [hotels-sample-index](../../search-get-started-portal.md) that you can create in minutes using an Azure portal wizard.
5559

56-
If you don't have access to the Azure portal, you can create a hotels-quickstart-index by following the instructions in [Quickstart: Full text search](../../search-get-started-text.md).
57-
58-
Both indexes have a "Description" field that's suitable for demonstrating the semantic ranker.
59-
6060
1. Sign in to the [Azure portal](https://portal.azure.com/) and find your search service.
6161

62-
1. Under **Search management** > **Indexes**, open the hotels index. Make sure the index doesn't have a semantic configuration.
62+
1. Under **Search management** > **Indexes**, open the hotels-sample-index. Make sure the index doesn't have a semantic configuration.
6363

6464
:::image type="content" source="../../media/search-get-started-semantic/no-semantic-configuration.png" alt-text="Screenshot of an empty semantic configuration page in the Azure portal.":::
6565

66-
1. In **Search explorer**, enter this search string "good trails for running or biking and outdoor activities" so that you can view the response *before* semantic ranking is applied. Your response should be similar to the following example, as scored by the default L1 ranker for full text search. For readability, the example below selects just the "HotelName" and "Description" fields.
66+
1. To verify the index is operational, run a query. In **Search explorer**, enter this search string "good trails for running or biking and outdoor activities" so that you can view the response *before* semantic ranking is applied. Your response should be similar to the following example, as scored by the default BM25 L1 ranker for full text search. For readability, the example selects just the "HotelName" and "Description" fields.
6767

6868
```json
6969
"@odata.count": 11,

articles/search/includes/quickstarts/semantic-ranker-python.md

Lines changed: 19 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ We recommend a virtual environment for this quickstart:
2323

2424
1. Start Visual Studio Code.
2525

26-
1. Open the **semantic-search-quickstart.ipynb** file.
26+
1. Open the **semantic-search-quickstart.ipynb** file or create a new notebook.
2727

2828
1. Open the Command Palette by using **Ctrl+Shift+P**.
2929

@@ -52,7 +52,7 @@ It can take a minute to set up. If you run into problems, see [Python environmen
5252

5353
### Sign in to Azure
5454

55-
If you signed in to the [Azure portal](https://portal.azure.com), you're signed into Azure. If you aren't sure, use the Azure CLI or Azure PowerShell to log in: `az login` or `az connect`. If you have multiple tenants and subscriptions, see [Quickstart: Connect without keys](../../search-get-started-rbac/md) for help on how to connect.
55+
If you signed in to the [Azure portal](https://portal.azure.com), you're signed into Azure. If you aren't sure, use the Azure CLI or Azure PowerShell to log in: `az login` or `az connect`. If you have multiple tenants and subscriptions, see [Quickstart: Connect without keys](../../search-get-started-rbac.md) for help on how to connect.
5656

5757
## Update and query the index
5858

@@ -136,15 +136,15 @@ result = index_client.create_or_update_index(index)
136136
print(f' {result.name} updated')
137137
```
138138

139-
### Add semantic query parameters to a query
139+
### Add semantic parameters to a query
140140

141141
```python
142142
# Set up the search client
143143
search_client = SearchClient(endpoint=search_endpoint,
144144
index_name=index_name,
145145
credential=credential)
146146

147-
# Runs a semantic query (runs a BM25-ranked query and promotes the most relevant matches to the top)
147+
# Runs a semantic query
148148
results = search_client.search(query_type='semantic', semantic_configuration_name='semantic-config',
149149
search_text="walk to restaurants and shopping",
150150
select='HotelName,Description,Category', query_caption='extractive')
@@ -165,37 +165,16 @@ for result in results:
165165

166166
## Explaining the code
167167

168-
Add `SemanticConfiguration` to a search index definition. If you're updating an existing index, this modification doesn't require a reindexing because the structure of your documents is unchanged.
168+
This quickstart demonstrates how to add `SemanticConfiguration` to a search index definition. If you're updating an existing index, this modification doesn't require a reindexing because the structure of your documents is unchanged.
169169

170-
Provide the entire schema plus the new `SemanticConfiguration` section. We recommend getting the index schema from the search service to ensure you have a valid schema for the current index. If the schema payload differs in field definitions, the update fails.
170+
### Index updates
171171

172-
This example is the Python code for the Hotels sample index schema, plus the semantic configuration.
172+
To update the index, provide the entire schema plus the new `SemanticConfiguration` section. We recommend getting the index schema from the search service to ensure you have a valid schema for your update. If the schemas differ in field definitions or are missing other constructs, the update fails.
173173

174-
```python
175-
# Update the search schema, providing the entire schema plus the changes.
176-
index_client = SearchIndexClient(
177-
endpoint=search_endpoint, credential=credential)
178-
fields = [
179-
SimpleField(name="HotelId", type=SearchFieldDataType.String, key=True),
180-
SearchableField(name="HotelName", type=SearchFieldDataType.String, sortable=True),
181-
SearchableField(name="Description", type=SearchFieldDataType.String, analyzer_name="en.lucene"),
182-
SearchableField(name="Category", type=SearchFieldDataType.String, facetable=True, filterable=True, sortable=True),
183-
184-
SearchableField(name="Tags", collection=True, type=SearchFieldDataType.String, facetable=True, filterable=True),
185-
186-
SimpleField(name="ParkingIncluded", type=SearchFieldDataType.Boolean, facetable=True, filterable=True, sortable=True),
187-
SimpleField(name="LastRenovationDate", type=SearchFieldDataType.DateTimeOffset, facetable=True, filterable=True, sortable=True),
188-
SimpleField(name="Rating", type=SearchFieldDataType.Double, facetable=True, filterable=True, sortable=True),
189-
190-
ComplexField(name="Address", fields=[
191-
SearchableField(name="StreetAddress", type=SearchFieldDataType.String),
192-
SearchableField(name="City", type=SearchFieldDataType.String, facetable=True, filterable=True, sortable=True),
193-
SearchableField(name="StateProvince", type=SearchFieldDataType.String, facetable=True, filterable=True, sortable=True),
194-
SearchableField(name="PostalCode", type=SearchFieldDataType.String, facetable=True, filterable=True, sortable=True),
195-
SearchableField(name="Country", type=SearchFieldDataType.String, facetable=True, filterable=True, sortable=True),
196-
])
197-
]
174+
This example highlights the Python code that adds a semantic configuration to an index.
198175

176+
```python
177+
# New semantic configuration section in the index
199178
semantic_config = SemanticConfiguration(
200179
name="semantic-config",
201180
prioritized_fields=SemanticPrioritizedFields(
@@ -205,81 +184,21 @@ semantic_config = SemanticConfiguration(
205184
)
206185
)
207186

208-
# Create the semantic settings with the configuration
187+
# Create the semantic settings using the configuration
209188
semantic_search = SemanticSearch(configurations=[semantic_config])
210189

211-
scoring_profiles = []
212-
suggester = [{'name': 'sg', 'source_fields': ['Tags', 'Address/City', 'Address/Country']}]
213-
214-
# Create the search index with the semantic settings
215-
index = SearchIndex(name=index_name, fields=fields, suggesters=suggester, scoring_profiles=scoring_profiles, semantic_search=semantic_search)
190+
# Update the search index on the search service
191+
index = SearchIndex(name=index_name, fields=fields, semantic_search=semantic_search)
216192
result = index_client.create_or_update_index(index)
217-
print(f' {result.name} created')
218-
```
219-
220-
### Run your first query
221-
222-
Start with an empty query as a verification step, proving that the index is operational. You should get an unordered list of hotel names and descriptions, with a count of 50 indicating that there are fifty documents in the index.
223-
224-
```python
225-
# Run an empty query (returns selected fields, all documents)
226-
results = search_client.search(query_type='simple',
227-
search_text="*" ,
228-
select='HotelName,Description',
229-
include_total_count=True)
230-
231-
print ('Total Documents Matching Query:', results.get_count())
232-
for result in results:
233-
print(result["@search.score"])
234-
print(result["HotelName"])
235-
print(f"Description: {result['Description']}")
236-
```
237-
238-
### Run a text query
239-
240-
For comparison purposes, run a text query with BM25 relevance scoring. Full text search is invoked when you provide a query string. The response consists of ranked results, where higher scores are awarded to documents having more instances of matching terms, or more important terms.
241-
242-
In this query for *walk to restaurants and shopping*, Sublime Palace Hotel comes out on top because its description includes *site*. Terms that occur infrequently raise the search score of the document.
243-
244-
```python
245-
# Run a text query (returns a BM25-scored result set)
246-
results = search_client.search(query_type='simple',
247-
search_text="walk to restaurants and shopping" ,
248-
select='HotelName,HotelId,Description',
249-
include_total_count=True)
250-
251-
for result in results:
252-
print(result["@search.score"])
253-
print(result["HotelName"])
254-
print(f"Description: {result['Description']}")
255-
```
256-
257-
Output for the top 5 matches for a keyword search should be similar to the following example. The first result contains all three terms: walk, restaurants, shopping.
258-
259-
```
260-
7.9934134
261-
Foot Happy Suites
262-
Description: Downtown in the heart of the business district. Close to everything. Leave your car behind and walk to the park, shopping, and restaurants. Or grab one of our bikes and take your explorations a little further.
263-
6.563842
264-
Winter Panorama Resort
265-
Description: Plenty of great skiing, outdoor ice skating, sleigh rides, tubing and snow biking. Yoga, group exercise classes and outdoor hockey are available year-round, plus numerous options for shopping as well as great spa services. Newly-renovated with large rooms, free 24-hr airport shuttle & a new restaurant. Rooms/suites offer mini-fridges & 49-inch HDTVs.
266-
5.8222375
267-
Uptown Chic Hotel
268-
Description: Chic hotel near the city. High-rise hotel in downtown, within walking distance to theaters, art galleries, restaurants and shops. Visit Seattle Art Museum by day, and then head over to Benaroya Hall to catch the evening's concert performance.
269-
4.870869
270-
Roach Motel
271-
Description: Perfect Location on Main Street. Earn points while enjoying close proximity to the city's best shopping, restaurants, and attractions.
272-
4.1960583
273-
Swirling Currents Hotel
274-
Description: Spacious rooms, glamorous suites and residences, rooftop pool, walking access to shopping, dining, entertainment and the city center. Each room comes equipped with a microwave, a coffee maker and a minifridge. In-room entertainment includes complimentary W-Fi and flat-screen TVs.
193+
print(f' {result.name} updated')
275194
```
276195

277-
### Run a semantic query
196+
### Query parameters
278197

279-
Now add semantic ranking. New parameters include `query_type` and `semantic_configuration_name`.
198+
Required semantic parameters include `query_type` and `semantic_configuration_name`. Optionally, you can add captions to extract portions of the text and apply hit highlighting to the important terms and phrases.
280199

281200
```python
282-
# Runs a semantic query (runs a BM25-ranked query and promotes the most relevant matches to the top)
201+
# Runs a semantic query
283202
results = search_client.search(query_type='semantic', semantic_configuration_name='semantic-config',
284203
search_text="walk to restaurants and shopping",
285204
select='HotelName,Description,Category', query_caption='extractive')
@@ -298,7 +217,7 @@ for result in results:
298217
print(f"Caption: {caption.text}\n")
299218
```
300219

301-
Output for this query should look similar to the following example. It's the same search string as the previous query, but notice that the semantic ranker elevates the last result in the previous example to first place. Results are ranked by the `rerankerScore` property and results in the 2 category are considered to be of [moderate relevance](../../semantic-search-overview.md#how-ranking-is-scored).
220+
Output for this query should look similar to the following example. Results are ranked by the `rerankerScore` property and results in the 2 category are considered to be of [moderate relevance](../../semantic-search-overview.md#how-ranking-is-scored).
302221

303222
```
304223
2.9116947650909424
@@ -331,7 +250,7 @@ Caption: <em>Sublime Cliff Hotel </em>is located in the heart of the historic ce
331250

332251
In this final query, return semantic answers.
333252

334-
Semantic ranker can produce an answer to a query string that has the characteristics of a question. The generated answer is extracted verbatim from your content so it won't include composed content like what you get from a chat completion model. If the semantic answer isn't useful for your scenario, you can omit `semantic_answers` from your code.
253+
Semantic ranker can produce an answer to a query string that has the characteristics of a question. The generated answer is extracted verbatim from your content so it won't include composed content like what you might expect from a chat completion model. If the semantic answer isn't useful for your scenario, you can omit `semantic_answers` from your code.
335254

336255
To get a semantic answer, the question and answer must be closely aligned, and the model must find content that clearly answers the question. If potential answers fail to meet a confidence threshold, the model doesn't return an answer. For demonstration purposes, the question in this example is designed to get a response so that you can see the syntax.
337256

0 commit comments

Comments
 (0)