Skip to content

Commit 040a15f

Browse files
committed
Standard H2s and H3s for all language versions
1 parent 5504092 commit 040a15f

File tree

3 files changed

+103
-25
lines changed

3 files changed

+103
-25
lines changed

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

Lines changed: 56 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ms.date: 06/27/2025
1010

1111
[!INCLUDE [Semantic ranker introduction](semantic-ranker-intro.md)]
1212

13-
> [!TIP]
13+
> [!TIP]
1414
> You can [download the source code](https://github.com/Azure-Samples/azure-search-dotnet-samples/tree/main/quickstart-semantic-search/SemanticSearchQuickstart) to start with a finished project or follow these steps to create your own.
1515
1616
## Set up the client
@@ -31,6 +31,10 @@ We recommend [Visual Studio](https://visualstudio.microsoft.com/vs/community/) f
3131

3232
1. Select **Install** to add the assembly to your project and solution.
3333

34+
### Sign in to Azure
35+
36+
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.
37+
3438
### Create a search client
3539

3640
1. In *Program.cs*, add the following `using` directives.
@@ -68,15 +72,22 @@ We recommend [Visual Studio](https://visualstudio.microsoft.com/vs/community/) f
6872

6973
## Update and query the index
7074

71-
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).
75+
In this section, you update a search index and send a query that invokes semantic ranking. The code runs all operations in sequence, from index updates through a series of queries. For more information about each step, see [Explaining the code](#explaining-the-code). The code performs two types of tasks:
76+
77+
+ [Add a semantic configuration to an index](#add-a-semantic-configuration-to-the-hotels-sample-index)
78+
+ [Add semantic parameters to a query](#add-semantic-parameters-to-a-query)
7279

7380
### Add a semantic configuration to the hotels-sample-index
7481

82+
```csharp
7583
CODE GOES HERE
84+
```
7685

77-
### Add semantic query parameters to a query
86+
### Add semantic parameters to a query
7887

88+
```csharp
7989
CODE GOES HERE
90+
```
8091

8192
### Run the program
8293

@@ -86,18 +97,45 @@ Output includes messages from [Console.WriteLine](/dotnet/api/system.console.wri
8697

8798
## Explaining the code
8899

89-
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.
100+
This section explains the updates to the index and queries. If you're updating an existing index, the additional of a semantic configuration doesn't require a reindexing because the structure of your documents is unchanged.
90101

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)
102+
### Index updates
93103

94-
### Update an index with a semantic configuration
104+
To update the index, provide the existing schema in its entirety, plus the new `SemanticConfiguration` section. We recommend retrieving the index schema from the search service to ensure you're working with the current version. If the original and updated schemas differ in field definitions or other constructs, the update fails.
95105

96-
TBD
106+
This example highlights the C# code that adds a semantic configuration to an index.
107+
108+
```csharp
109+
CODE GOES HERE
110+
```
97111

98-
### Query the index using semantic parameters
112+
### Query parameters
99113

100-
Here's a query that invokes semantic ranker, with search options for specifying parameters:
114+
Required semantic parameters include `query_type` and `semantic_configuration_name`. Here is an example of a basic semantic query using the minimum parameters.
115+
116+
```csharp
117+
Console.WriteLine("Example of a semantic query.");
118+
119+
options = new SearchOptions()
120+
{
121+
QueryType = Azure.Search.Documents.Models.SearchQueryType.Semantic,
122+
SemanticSearch = new()
123+
{
124+
SemanticConfigurationName = "semantic-config"
125+
}
126+
};
127+
options.Select.Add("HotelName");
128+
options.Select.Add("Category");
129+
options.Select.Add("Description");
130+
131+
// response = srchclient.Search<Hotel>("*", options);
132+
response = srchclient.Search<Hotel>("walking distance to live music", options);
133+
WriteDocuments(response);
134+
```
135+
136+
### Return captions
137+
138+
Optionally, you can add captions to extract portions of the text and apply hit highlighting to the important terms and phrases. This query adds captions.
101139

102140
```csharp
103141
Console.WriteLine("Example of a semantic query.");
@@ -116,16 +154,18 @@ options.Select.Add("Category");
116154
options.Select.Add("Description");
117155

118156
// response = srchclient.Search<Hotel>("*", options);
119-
response = srchclient.Search<Hotel>("restaurant on site", options);
157+
response = srchclient.Search<Hotel>("walking distance to live music", options);
120158
WriteDocuments(response);
121159
```
122160

123-
For comparison, here are results from a query that uses the default BM25 ranking, based on term frequency and proximity. Given the query "restaurant on site", the BM25 ranking algorithm returns matches in the order shown in this screenshot, where the match on the "site" is considered more relevant because it's rare across the dataset:
161+
### Return semantic answers
124162

125-
:::image type="content" source="../../media/quickstart-semantic/bm25-ranking.png" alt-text="Screenshot showing matches ranked by BM25.":::
163+
In this final query, return semantic answers.
126164

127-
In contrast, when semantic ranking is applied to the same query ("restaurant on site"), the results are reranked based on semantic relevance to the query. This time, the top result is the hotel with the restaurant, which aligns better to user expectations.
128-
129-
:::image type="content" source="../../media/quickstart-semantic/semantic-ranking.png" alt-text="Screenshot showing matches ranked based on semantic ranking.":::
165+
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.
130166

167+
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.
131168

169+
```csharp
170+
CODE GOES HERE
171+
```

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ms.date: 06/27/2025
1010

1111
[!INCLUDE [Semantic ranker introduction](semantic-ranker-intro.md)]
1212

13-
> [!TIP]
13+
> [!TIP]
1414
> You can [download a finished notebook](https://github.com/Azure-Samples/azure-search-python-samples/tree/main/Quickstart-Semantic-Search) to start with a finished project or follow these steps to create your own.
1515
1616
## Set up the client
@@ -166,7 +166,7 @@ for result in results:
166166

167167
## Explaining the code
168168

169-
This section explains the updates to the index and queries. If you're updating an existing index, this modification doesn't require a reindexing because the structure of your documents is unchanged.
169+
This section explains the updates to the index and queries. If you're updating an existing index, the additional of a semantic configuration doesn't require a reindexing because the structure of your documents is unchanged.
170170

171171
### Index updates
172172

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

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,59 @@ We recommend [Visual Studio Code](https://code.visualstudio.com/download) with a
4141

4242
In this section, you make REST API calls to update a search index to include a semantic configuration, and then send a query that invokes semantic ranking. Visual Studio Code displays the response to each request in an adjacent pane. For more information about each step, see [Explaining the code](#explaining-the-code).
4343

44-
```json
44+
+ [Add a semantic configuration to an index](#add-a-semantic-configuration-to-the-hotels-sample-index)
45+
+ [Add semantic parameters to a query](#add-semantic-parameters-to-a-query)
46+
47+
### Add a semantic configuration to the hotels-sample-index
48+
49+
```https
50+
TBD
51+
```
52+
53+
### Add semantic parameters to a query
54+
55+
```https
4556
TBD
4657
```
4758

4859
## Explaining the code
4960

50-
This section explains the REST API calls that you made to:
61+
This section explains the updates to the index and queries. If you're updating an existing index, the additional of a semantic configuration doesn't require a reindexing because the structure of your documents is unchanged.
62+
63+
### Index updates
64+
65+
To update the index, provide the existing schema in its entirety, plus the new `SemanticConfiguration` section. We recommend retrieving the index schema from the search service to ensure you're working with the current version. If the original and updated schemas differ in field definitions or other constructs, the update fails.
66+
67+
This example shows the JSON that adds a semantic configuration to an index.
68+
69+
```json
70+
TBD
71+
```
72+
73+
### Query parameters
5174

52-
+ [Update an index with a semantic configuration](#add-a-semantic-configuration-to-the-index)
53-
+ [Query the index using semantic parameters](#add-semantic-ranking-to-queries)
75+
Required semantic parameters include `query_type` and `semantic_configuration_name`. Here is an example of a basic semantic query using the minimum parameters.
5476

55-
### Update an index with a semantic configuration
77+
```json
78+
TBD
79+
```
5680

81+
### Return captions
82+
83+
Optionally, you can add captions to extract portions of the text and apply hit highlighting to the important terms and phrases. This query adds captions.
84+
85+
```json
5786
TBD
87+
```
88+
89+
### Return semantic answers
90+
91+
In this final query, return semantic answers.
92+
93+
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.
5894

59-
### Query the index using semantic parameters
95+
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.
6096

61-
TBD
97+
```json
98+
TBD
99+
```

0 commit comments

Comments
 (0)