You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/search/semantic-how-to-query-rewrite.md
+21-5Lines changed: 21 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,7 @@ ms.author: eur
8
8
ms.service: azure-ai-search
9
9
ms.custom:
10
10
- ignite-2024
11
+
- references_regions
11
12
ms.topic: how-to
12
13
ms.date: 11/19/2024
13
14
---
@@ -25,6 +26,21 @@ Search with query rewriting works like this:
25
26
26
27
Query rewriting is an optional feature. Without query rewriting, the search service just uses the original query to retrieve search results.
27
28
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
+
28
44
## Prerequisites
29
45
30
46
+ 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
52
68
"semanticConfiguration":"en-semantic-config",
53
69
"queryType":"semantic",
54
70
"queryRewrites":"generative|count-5",
55
-
"queryLanguage":"en",
71
+
"queryLanguage":"en-US",
56
72
"debug":"queryRewrites",
57
73
"top": 1
58
74
}
@@ -64,7 +80,8 @@ In this REST API example, we use [Search Documents](/rest/api/searchservice/docu
64
80
- We set "semanticConfiguration" to a [predefined semantic configuration](semantic-how-to-configure.md) embedded in your index.
65
81
- 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.
66
82
- 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:
- 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.
69
86
- We set "top" to 1 to return only the top search result.
70
87
@@ -132,9 +149,8 @@ Here are some key points to note:
132
149
- Because we set the "debug" property to "queryRewrites", the response includes a `@search.debug` object with the text input query and query rewrites.
133
150
- Because we set the "queryRewrites" property to "generative|count-5", the response includes up to five query rewrites.
134
151
- 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.
136
152
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.
138
154
139
155
```json
140
156
"@search.debug": {
@@ -204,7 +220,7 @@ POST https://[search-service-name].search.windows.net/indexes/hotels-sample-inde
0 commit comments