|
| 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) |
0 commit comments