Skip to content

Commit 337e997

Browse files
authored
Merge pull request #1925 from HeidiSteen/heidist-freshness
[azure search] semantic ranking doc fixes
2 parents 71ac95e + 2228f16 commit 337e997

9 files changed

+146
-50
lines changed

articles/search/hybrid-search-how-to-query.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ POST https://{{search-service-name}}.search.windows.net/indexes/{{index-name}}/d
228228

229229
Assuming that you [enabled semantic ranker](semantic-how-to-enable-disable.md) and your index definition includes a [semantic configuration](semantic-how-to-query-request.md), you can formulate a query that includes vector search and keyword search, with semantic ranking over the merged result set. Optionally, you can add captions and answers.
230230

231+
Whenever you use semantic ranking with vectors, make sure `k` is set to 50. Semantic ranker uses up to 50 matches as input. Specifying less than 50 deprives the semantic ranking models of necessary inputs.
232+
231233
```http
232234
POST https://{{search-service-name}}.search.windows.net/indexes/{{index-name}}/docs/search?api-version=2024-07-01
233235
Content-Type: application/json
@@ -306,7 +308,7 @@ api-key: {{admin-api-key}}
306308

307309
+ Prefiltering is applied before query execution. If prefilter reduces the search area to 100 documents, the vector query executes over the "DescriptionVector" field for those 100 documents, returning the k=50 best matches. Those 50 matching documents then pass to RRF for merged results, and then to semantic ranker.
308310

309-
+ Postfilter is applied after query execution. If k=50 returns 50 matches on the vector query side, then the post-filter is applied to the 50 matches, reducing results that meet filter criteria, leaving you with fewer than 50 documents to pass to semantic ranker.
311+
+ Postfilter is applied after query execution. If k=50 returns 50 matches on the vector query side, followed by a post-filter applied to the 50 matches, your results are reduced by the number of documents that meet filter criteria. This leaves you with fewer than 50 documents to pass to semantic ranker. Keep this in mind if you're using semantic ranking. The semantic ranker works best if it has 50 documents as input.
310312

311313
## Set maxTextRecallSize and countAndFacetMode (preview)
312314

articles/search/search-api-migration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Effective March 29, 2024 and applicable to all [supported REST APIs](/rest/api/s
7272

7373
+ For all API versions, updates on July 14, 2023 to the Microsoft-hosted semantic models made semantic ranker language-agnostic, effectively decommissioning the `queryLanguage` property. There's no "breaking change" in code, but the property is ignored.
7474

75-
See [Migrate from preview version](semantic-how-to-configure.md#migrate-from-preview-versions) to transition your code to use `semanticConfiguration`.
75+
See [Migrate from preview version](semantic-code-migration.md) to transition your code to use `semanticConfiguration`.
7676

7777
## Upgrade to 2024-11-01-preview
7878

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
---
2+
title: Migrate semantic ranking code
3+
titleSuffix: Azure AI Search
4+
description: Migrate semantic ranking code from preview to stable versions, and now to newer preview versions.
5+
manager: nitinme
6+
author: HeidiSteen
7+
ms.author: heidist
8+
ms.service: azure-ai-search
9+
ms.custom:
10+
- ignite-2023
11+
ms.topic: how-to
12+
ms.date: 12/10/2024
13+
---
14+
15+
# Migrate semantic ranking code from previous versions
16+
17+
If your semantic ranking code was written against early preview APIs, this article identifies the code changes necessary for migrating to newer API versions. Breaking changes for semantic ranker are limited to query logic in recent APIs, but if your code was written against the initial preview version, you might need to change your semantic configuration as well.
18+
19+
## Breaking changes
20+
21+
There are two breaking changes for semantic ranker across REST API versions:
22+
23+
+ `searchFields` was replaced by `semanticConfiguration` in 2021-04-30-preview
24+
+ `queryLanguage` was ignored starting in 2023-07-01-preview, but reinstated for query rewrite in 2024-11-01-preview
25+
26+
Other version-specific updates pertain to new capabilities, but don't break existing code and are therefore not breaking changes.
27+
28+
If you're using Azure SDKs, multiple APIs have been renamed over time. The SDK change logs provide the details.
29+
30+
## API versions providing semantic ranking
31+
32+
Check your code for the REST API version or SDK package version to confirm which one provides semantic ranking. The following API versions have some level of support for semantic ranking.
33+
34+
| Release type | REST API version | Semantic ranker updates |
35+
|--|--|--|
36+
| initial | [2020-06-30-preview](/rest/api/searchservice/preview-api/search-documents) | Adds `queryType=semantic` to Search Documents |
37+
| preview | [2021-04-30-preview](/rest/api/searchservice/preview-api/search-documents) | Adds `semanticConfiguration` to Create or Update Index |
38+
| preview | [2023-07-01-preview](/rest/api/searchservice/preview-api/search-documents) | Updates `semanticConfiguration`. Starting on July 14, 2023 updates to the Microsoft-hosted semantic models made semantic ranker language-agnostic, effectively decommissioning the `queryLanguage` property for semantic ranking. There's no breaking change in code, but the property is ignored. Customers were advised to remove this property from code.|
39+
| preview | [2023-10-01-preview](/rest/api/searchservice/operation-groups?view=rest-searchservice-2023-10-01-preview&preserve-view=true) | Adds `semanticQuery` to send a query used only for reranking purposes. |
40+
| stable | [2023-11-01](/rest/api/searchservice/operation-groups?view=rest-searchservice-2023-11-01&preserve-view=true) | Generally available. Introduced changes to `semanticConfiguration` that progressed to the stable version. If your code targets this version or later, it's compatible with newer API versions unless you adopt new preview features.|
41+
| preview | [2024-05-01-preview](/rest/api/searchservice/operation-groups?view=rest-searchservice-2024-05-01-preview&preserve-view=true) | No change |
42+
| stable | [2024-07-01](/rest/api/searchservice/indexes/create-or-update?view=rest-searchservice-2024-07-01&preserve-view=true) | No change |
43+
| preview | [2024-09-01-preview](/rest/api/searchservice/operation-groups?view=rest-searchservice-2024-09-01-preview&preserve-view=true) | No change |
44+
| preview | [2024-11-01-preview](/rest/api/searchservice/operation-groups?view=rest-searchservice-2024-11-01-preview&preserve-view=true) | Adds query rewrite. The `queryLanguage` property is now required if you use [query rewrite (preview)](semantic-how-to-query-rewrite.md). |
45+
46+
## Change logs for Azure SDKs
47+
48+
Azure SDKs are on an independent release schedule. You should check the change logs to determine which packages provide semantic features and whether any APIs have been renamed.
49+
50+
+ [Azure SDK for .NET change log](https://github.com/Azure/azure-sdk-for-net/blob/Azure.Search.Documents_11.5.1/sdk/search/Azure.Search.Documents/CHANGELOG.md#1150-2023-11-10&preserve-view=true)
51+
+ [Azure SDK for Python change log](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/search/azure-search-documents/CHANGELOG.md#1140-2023-10-13&preserve-view=true)
52+
+ [Azure SDK for Java change log](https://github.com/Azure/azure-sdk-for-java/blob/azure-search-documents_11.6.1/sdk/search/azure-search-documents/CHANGELOG.md#1160-2023-11-13&preserve-view=true)
53+
+ [Azure SDK for JavaScript change log](https://github.com/Azure/azure-sdk-for-js/blob/%40azure/search-documents_12.0.0/sdk/search/search-documents/CHANGELOG.md#1200-2023-11-13&preserve-view=true)
54+
55+
## 2024-11-01-preview
56+
57+
+ Adds [query rewrite](semantic-how-to-query-rewrite.md) to Search Documents.
58+
+ Requires `queryLanguage` for query rewrite workloads. For a list of valid values, see the [REST API](/rest/api/searchservice/documents/search-post?view=rest-searchservice-2024-11-01-preview#querylanguage&preserve-view=true).
59+
60+
## 2024-09-01-preview
61+
62+
No changes to semantic ranking syntax from the 2024-07-01 stable version.
63+
64+
## 2024-07-01
65+
66+
No changes to semantic ranking syntax from the 2024-05-01-preview version.
67+
68+
Don't use this API version. It implements a vector query syntax that's incompatible with any newer API version.
69+
70+
## 2024-05-01-preview
71+
72+
No changes to semantic ranking syntax from the 2024-03-01-preview version.
73+
74+
## 2024-03-01-preview
75+
76+
No changes to semantic ranking syntax from the 2023-10-01-preview version, but vector queries are introduced. Semantic ranking now applies to responses from hybrid and vector queries. You can apply reranking on any human-readable text fields in the response, assuming the fields are listed in `prioritizedFields`.
77+
78+
## 2023-11-01
79+
80+
+ Excludes `SemanticDebug` and `semanticQuery`, otherwise the same as the 2023-10-01-preview version.
81+
82+
## 2023-10-01-preview
83+
84+
+ Adds `semanticQuery`
85+
86+
## 2023-07-01-preview
87+
88+
+ Adds `semanticErrorHandling`, `semanticMaxWaitInMilliseconds`.
89+
+ Adds numerous semantic-related fields to the response, such as `SemanticDebug` and `SemanticErrorMode`.
90+
+ Ignores `queryLanguage`, it's no longer used in semantic ranking.
91+
92+
Starting on July 14, 2023, semantic ranker is language agnostic. In preview versions, semantic ranking would deprioritize results differing from the `querylanguage` specified by the field analyzer. However, the `queryLanguage` property is still applicable to [spell correction](speller-how-to-add.md) and the short list of languages supported by that feature.
93+
94+
## 2021-04-30-preview
95+
96+
+ Semantic support is through [Search Documents](/rest/api/searchservice/preview-api/search-documents) and [Create or Update Index](/rest/api/searchservice/preview-api/create-or-update-index) preview API calls.
97+
+ Adds `semanticConfiguration` to a search index. A semantic configuration has a name and a prioritized field list.
98+
+ Adds ``prioritizedFields`.
99+
100+
The `searchFields` property is no longer used to prioritize fields. In all versions moving forward, `semanticConfiguration.prioritizedFields` replaces `searchFields` as the mechanism for specifying which fields to use for L2 ranking.
101+
102+
## 2020-06-30-preview
103+
104+
+ Semantic support is through a [Search Documents](/rest/api/searchservice/preview-api/search-documents) preview API call.
105+
+ Adds `queryType=semantic` to the query request.
106+
+ Adapts `searchFields` so that if the query type is semantic, the `searchFields` property determines the priority order of field inputs to the semantic ranker.
107+
+ Adds `captions`, `answers`, and `highlights` to the query response.
108+
109+
## Next steps
110+
111+
Test your semantic configuration migration by running a semantic query.
112+
113+
> [!div class="nextstepaction"]
114+
> [Create a semantic query](semantic-how-to-query-request.md)

articles/search/semantic-how-to-configure.md

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,17 @@ ms.service: azure-ai-search
99
ms.custom:
1010
- ignite-2023
1111
ms.topic: how-to
12-
ms.date: 10/20/2024
12+
ms.date: 12/10/2024
1313
---
1414

1515
# Configure semantic ranker and return captions in search results
1616

1717
Semantic ranking iterates over an initial result set, applying an L2 ranking methodology that promotes the most semantically relevant results to the top of the stack. You can also get semantic captions, with highlights over the most relevant terms and phrases, and [semantic answers](semantic-answers.md).
1818

19-
This article explains how to configure a search index for semantic reranking.
19+
This article explains how to configure a search index for semantic reranking.
20+
21+
> [!NOTE]
22+
> If you have existing code that calls preview or previous API versions, see [Migrate semantic ranking code](semantic-code-migration.md) for help with modifying your code.
2023
2124
## Prerequisites
2225

@@ -28,10 +31,10 @@ This article explains how to configure a search index for semantic reranking.
2831

2932
## Choose a client
3033

31-
You can use any of the following tools and software development kits (SDKs) to add a semantic configuration:
34+
You can specify a semantic configuration on new or existing indexes, using any of the following tools and software development kits (SDKs) to add a semantic configuration:
3235

3336
+ [Azure portal](https://portal.azure.com), using the index designer to add a semantic configuration.
34-
+ [Visual Studio Code](https://code.visualstudio.com/download) with the [REST client](https://marketplace.visualstudio.com/items?itemName=humao.rest-client)
37+
+ [Visual Studio Code](https://code.visualstudio.com/download) with the [REST client](https://marketplace.visualstudio.com/items?itemName=humao.rest-client) and a [Create or Update Index (REST) API](/rest/api/searchservice/indexes/create-or-update).
3538
+ [Azure SDK for .NET](https://www.nuget.org/packages/Azure.Search.Documents)
3639
+ [Azure SDK for Python](https://pypi.org/project/azure-search-documents)
3740
+ [Azure SDK for Java](https://central.sonatype.com/artifact/com.azure/azure-search-documents)
@@ -155,31 +158,6 @@ SearchIndex searchIndex = new(indexName)
155158

156159
---
157160

158-
## Migrate from preview versions
159-
160-
If your semantic ranking code is using preview APIs, this section explains how to migrate to stable versions. You can check the change logs for verification of general availability:
161-
162-
+ [2024-07-01 (REST)](/rest/api/searchservice/indexes/create-or-update?view=rest-searchservice-2024-07-01&preserve-view=true)
163-
+ [Azure SDK for .NET (11.5) change log](https://github.com/Azure/azure-sdk-for-net/blob/Azure.Search.Documents_11.5.1/sdk/search/Azure.Search.Documents/CHANGELOG.md#1150-2023-11-10)
164-
+ [Azure SDK for Python (11.4) change log](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/search/azure-search-documents/CHANGELOG.md#1140-2023-10-13)
165-
+ [Azure SDK for Java (11.6) change log](https://github.com/Azure/azure-sdk-for-java/blob/azure-search-documents_11.6.1/sdk/search/azure-search-documents/CHANGELOG.md#1160-2023-11-13)
166-
+ [Azure SDK for JavaScript (12.0) change log](https://github.com/Azure/azure-sdk-for-js/blob/%40azure/search-documents_12.0.0/sdk/search/search-documents/CHANGELOG.md#1200-2023-11-13)
167-
168-
169-
### queryLanguage for semantic ranker
170-
171-
As of July 14, 2023, semantic ranker is language agnostic. It can rerank results composed of multilingual content, with no bias towards a specific language. In preview versions, semantic ranking would deprioritize results differing from the language specified by the field analyzer.
172-
173-
Stop using `queryLanguage` in your code if you were using it for semantic ranking. The `queryLanguage` property is still applicable to features such as [spell correction](speller-how-to-add.md), but not to semantic ranking.
174-
175-
### searchFields for semantic ranker
176-
177-
For the REST API and all SDK packages targeting version `2021-04-30-Preview` and later, the `searchFields` property is no longer used for semantic ranking.
178-
179-
Instead, use the `semanticConfiguration` property (in a search index) to determine which search fields are used in semantic ranking. To specify field prioritization, add a `semanticConfiguration` to in an index schema following the [instructions in this article](#add-a-semantic-configuration).
180-
181-
You can keep `searchFields` in query requests if you're using it to limit full text search to the list of named fields.
182-
183161
## Next steps
184162

185163
Test your semantic configuration by running a semantic query.

articles/search/semantic-how-to-enable-disable.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ ms.service: azure-ai-search
1010
ms.custom:
1111
- ignite-2023
1212
ms.topic: how-to
13-
ms.date: 10/28/2024
13+
ms.date: 12/10/2024
1414
---
1515

1616
# Enable or disable semantic ranker
1717

18-
Semantic ranker is a premium feature billed by usage. By default, semantic ranker is turned off when you create a new search service, but anyone with *Contributor* permissions can enable it. If you don't want anyone enabling it inadvertently, you can [disable it using the REST API](#disable-semantic-ranker-using-the-rest-api).
18+
Semantic ranker is a premium feature billed by usage. By default, semantic ranker is turned off when you create a new search service, but anyone with *Contributor* permissions can enable it. If you don't want anyone enabling it inadvertently, you can [disable it service-wide using the management REST API](#disable-semantic-ranker-using-the-rest-api).
1919

2020
## Check availability
2121

articles/search/semantic-how-to-query-request.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ ms.custom:
1111
- ignite-2023
1212
- ignite-2024
1313
ms.topic: how-to
14-
ms.date: 11/19/2024
14+
ms.date: 12/10/2024
1515
---
1616

1717
# Add semantic ranking to queries in Azure AI Search
1818

1919
You can apply semantic ranking to text queries, hybrid queries, and vector queries if your search documents contain string fields and the [vector query has a text representation](vector-search-how-to-query.md#query-with-integrated-vectorization) in the search document.
2020

21-
This article explains how to invoke the semantic ranker on queries.
21+
This article explains how to invoke the semantic ranker on queries. It assumes you're using the most recent stable or preview APIs. For help with older versions, see [Migrate semantic ranking code](semantic-code-migration.md).
2222

2323
## Prerequisites
2424

articles/search/semantic-search-overview.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ms.service: azure-ai-search
1010
ms.custom:
1111
- ignite-2023
1212
ms.topic: concept-article
13-
ms.date: 09/24/2024
13+
ms.date: 12/10/2024
1414
---
1515

1616
# Semantic ranking in Azure AI Search
@@ -20,13 +20,13 @@ In Azure AI Search, *semantic ranker* is a feature that measurably improves sear
2020
Semantic ranker is a premium feature, billed by usage. We recommend this article for background, but if you'd rather get started, [follow these steps](#how-to-get-started-with-semantic-ranker).
2121

2222
> [!NOTE]
23-
> Semantic ranker doesn't use generative AI or vectors. If you're looking for vector support and similarity search, see [Vector search in Azure AI Search](vector-search-overview.md) for details.
23+
> Semantic ranker doesn't use generative AI or vectors. If you're looking for vectors and similarity search, see [Vector search in Azure AI Search](vector-search-overview.md) for details.
2424
2525
## What is semantic ranking?
2626

27-
Semantic ranker is a collection of query-side capabilities that improve the quality of an initial [BM25-ranked](index-similarity-and-scoring.md) or [RRF-ranked](hybrid-search-ranking.md) search result for text-based queries, vector queries, and hybrid queries. When you enable it on your search service, semantic ranking extends the query execution pipeline in two ways:
27+
Semantic ranker is a collection of query-side capabilities that improve the quality of an initial [BM25-ranked](index-similarity-and-scoring.md) or [RRF-ranked](hybrid-search-ranking.md) search result for text-based queries, vector queries, and hybrid queries. When you enable it on your search service, semantic ranking extends the query execution pipeline in two ways:
2828

29-
* First, it adds secondary ranking over an initial result set that was scored using BM25 or Reciprocal Rank Fusion (RRF). This secondary ranking uses multi-lingual, deep learning models adapted from Microsoft Bing to promote the most semantically relevant results.
29+
* First, it adds secondary ranking over an initial result set that was scored using BM25 or Reciprocal Rank Fusion (RRF). This secondary ranking uses multi-lingual, deep learning models adapted from Microsoft Bing to promote the most semantically relevant results.
3030

3131
* Second, it extracts and returns captions and answers in the response, which you can render on a search page to improve the user's search experience.
3232

@@ -72,11 +72,11 @@ In semantic ranking, the query subsystem passes search results as an input to su
7272

7373
1. Summarization output is a summary string for each document, composed of the most relevant information from each field. Summary strings are sent to the ranker for scoring, and to machine reading comprehension models for captions and answers.
7474

75-
The maximum length of each generated summary string passed to the semantic ranker is 256 tokens.
75+
As of November 2024, the maximum length of each generated summary string passed to the semantic ranker is 2,048 tokens. Previously, it was 256 tokens.
7676

7777
### How ranking is scored
7878

79-
Scoring is done over the caption, and any other content from the summary string that fills out the 256 token length.
79+
Scoring is done over the caption, and any other content from the summary string that fills out the 2,048 token length.
8080

8181
1. Captions are evaluated for conceptual and semantic relevance, relative to the query provided.
8282

@@ -131,7 +131,7 @@ Semantic ranker is available on search services at the Basic and higher tiers, s
131131

132132
When you enable semantic ranker, choose a pricing plan for the feature:
133133

134-
* At lower query volumes (under 1000 monthly), semantic ranking is free.
134+
* At lower query volumes (under 1,000 monthly), semantic ranking is free.
135135
* At higher query volumes, choose the standard pricing plan.
136136

137137
The [Azure AI Search pricing page](https://azure.microsoft.com/pricing/details/search/) shows you the billing rate for different currencies and intervals.

0 commit comments

Comments
 (0)