Skip to content

Commit 6261973

Browse files
Merge pull request #1350 from eric-urban/eur/query-rewrite-edits
query rewrite edit
2 parents 69e6038 + afd1b26 commit 6261973

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

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

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ ms.author: eur
88
ms.service: azure-ai-search
99
ms.custom:
1010
- ignite-2024
11+
- references_regions
1112
ms.topic: how-to
1213
ms.date: 11/19/2024
1314
---
@@ -25,6 +26,21 @@ Search with query rewriting works like this:
2526

2627
Query rewriting is an optional feature. Without query rewriting, the search service just uses the original query to retrieve search results.
2728

29+
> [!NOTE]
30+
> Query rewriting is currently available in the East US, North Europe, and Southeast Asia regions.
31+
32+
## Why use query rewriting?
33+
34+
When you enable query rewriting in Azure AI Search, you might or might not see higher BM25 scores, which indicate how relevant a document is to a query. Query rewriting uses generative AI to expand the original query, adding more terms and refining search results.
35+
36+
When query rewriting might be helpful:
37+
- Correcting typos or spelling errors in user queries.
38+
- Expanding queries with synonyms to improve search results.
39+
40+
When query rewriting might not be helpful:
41+
- For highly specific queries that require exact matches.
42+
- When searching for unique identifiers or product codes.
43+
2844
## Prerequisites
2945

3046
+ A search service, Basic tier or higher, with [semantic ranker enabled](semantic-how-to-enable-disable.md). Review [semantic ranking](semantic-search-overview.md) if you need an introduction to the feature.
@@ -52,7 +68,7 @@ In this REST API example, we use [Search Documents](/rest/api/searchservice/docu
5268
"semanticConfiguration":"en-semantic-config",
5369
"queryType":"semantic",
5470
"queryRewrites":"generative|count-5",
55-
"queryLanguage":"en",
71+
"queryLanguage":"en-US",
5672
"debug":"queryRewrites",
5773
"top": 1
5874
}
@@ -64,7 +80,8 @@ In this REST API example, we use [Search Documents](/rest/api/searchservice/docu
6480
- We set "semanticConfiguration" to a [predefined semantic configuration](semantic-how-to-configure.md) embedded in your index.
6581
- We set "queryType" to "semantic". We either need to set "queryType" to "semantic" or include a nonempty "semanticQuery" property in the request. [Semantic ranking](semantic-search-overview.md) is required for query rewriting.
6682
- We set "queryRewrites" to "generative|count-5" to get up to five query rewrites. You can set the count to any value between 1 and 10.
67-
- We set "queryLanguage" to the target language ("en") of the query rewrites.
83+
- We set "queryLanguage" to the target language ("en-US") of the query rewrites. The supported locales are:
84+
`en-AU`, `en-CA`, `en-GB`, `en-IN`, `en-US`, `ar-EG`, `ar-JO`, `ar-KW`, `ar-MA`, `ar-SA`, `bg-BG`, `bn-IN`, `ca-ES`, `cs-CZ`, `da-DK`, `de-DE`, `el-GR`, `es-ES`, `es-MX`, `et-EE`, `eu-ES`, `fa-AE`, `fi-FI`, `fr-CA`, `fr-FR`, `ga-IE`, `gl-ES`, `gu-IN`, `he-IL`, `hi-IN`, `hr-BA`, `hr-HR`, `hu-HU`, `hy-AM`, `id-ID`, `is-IS`, `it-IT`, `ja-JP`, `kn-IN`, `ko-KR`, `lt-LT`, `lv-LV`, `ml-IN`, `mr-IN`, `ms-BN`, `ms-MY`, `nb-NO`, `nl-BE`, `nl-NL`, `no-NO`, `pa-IN`, `pl-PL`, `pt-BR`, `pt-PT`, `ro-RO`, `ru-RU`, `sk-SK`, `sl-SL`, `sr-BA`, `sr-ME`, `sr-RS`, `sv-SE`, `ta-IN`, `te-IN`, `th-TH`, `tr-TR`, `uk-UA`, `ur-PK`, `vi-VN`, `zh-CN`, `zh-TW`.
6885
- We set "debug" to "queryRewrites" to get the query rewrites in the response. Set the `"debug": "queryRewrites"` property for testing purposes. For better performance, don't use debug in production.
6986
- We set "top" to 1 to return only the top search result.
7087
@@ -132,9 +149,8 @@ Here are some key points to note:
132149
- Because we set the "debug" property to "queryRewrites", the response includes a `@search.debug` object with the text input query and query rewrites.
133150
- Because we set the "queryRewrites" property to "generative|count-5", the response includes up to five query rewrites.
134151
- The `"inputQuery"` value is the query sent to the generative model for query rewriting. The input query isn't always the same as the user's `"search"` query.
135-
- The top search score (58.992092) can be considerably higher than the search score without query rewrites.
136152

137-
Here's an example of a response without query rewrites. If you don't use query rewrites for this specific query and sample data, the top search score (7.774868) is lower than the search score with query rewrites.
153+
Here's an example of a response without query rewrites.
138154

139155
```json
140156
"@search.debug": {
@@ -204,7 +220,7 @@ POST https://[search-service-name].search.windows.net/indexes/hotels-sample-inde
204220
"semanticConfiguration":"en-semantic-config",
205221
"queryType":"semantic",
206222
"queryRewrites":"generative|count-5",
207-
"queryLanguage":"en",
223+
"queryLanguage":"en-US",
208224
"debug":"queryRewrites",
209225
"top": 1
210226
}

0 commit comments

Comments
 (0)