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-request.md
+23-15Lines changed: 23 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ ms.service: azure-ai-search
10
10
ms.custom:
11
11
- ignite-2023
12
12
ms.topic: how-to
13
-
ms.date: 09/24/2024
13
+
ms.date: 11/19/2024
14
14
---
15
15
16
16
# Add semantic ranking to queries in Azure AI Search
@@ -51,8 +51,11 @@ A few query capabilities bypass relevance scoring, which makes them incompatible
51
51
52
52
## Set up the query
53
53
54
-
By default, queries don't use semantic ranking. To use semantic ranking, two different parameters may be used. Each parameter supports a different set of scenarios:
54
+
By default, queries don't use semantic ranking. To use semantic ranking, two different parameters can be used. Each parameter supports a different set of scenarios.
55
55
56
+
Semantic queries, whether specified through `search` plus `queryType`, or through `semanticQuery`, must be plain text and they can't be empty. Empty queries result in no semantic ranking being applied to the results.
57
+
58
+
<!--
56
59
1. Set `queryType` to `semantic`:
57
60
+ [Text search](search-lucene-query-architecture.md) with a simple plain text query. Empty queries result in no semantic ranking being applied to the results.
58
61
+ [Hybrid search](hybrid-search-overview.md).
@@ -61,22 +64,22 @@ By default, queries don't use semantic ranking. To use semantic ranking, two dif
61
64
+ [Text search](search-lucene-query-architecture.md) using the [simple](query-simple-syntax.md) or [full](query-lucene-syntax.md) syntax.
62
65
+ [Vector search](vector-search-overview.md).
63
66
+ [Hybrid search](hybrid-search-overview.md).
64
-
+ The query specified for `semanticQuery` must be a plain text query. Empty queries aren't supported.
65
-
66
-
The following table illustrates the supported scenarios depending on which semantic ranking parameter is used:
67
+
+ The query specified for `semanticQuery` must be a plain text query. Empty queries aren't supported. -->
67
68
68
-
| Semantic Ranker Parameter| Plain text search |[Simple text search syntax](query-simple-syntax.md)|[Full text search syntax](query-lucene-syntax.md)|[Vector search](vector-search-overview.md)|[Hybrid Search](hybrid-search-overview.md)|[Semantic answers](semantic-answers.md) and captions |
69
+
| Semantic ranker parameter|[Plain text search](search-query-create.md)|[Simple text search syntax](query-simple-syntax.md)|[Full text search syntax](query-lucene-syntax.md)|[Vector search](vector-search-how-to-query.md)|[Hybrid Search](hybrid-search-how-to-query.md)|[Semantic answers](semantic-answers.md) and captions |
69
70
|-|-|-|-|-|-|-|
70
-
| Set `queryType` to `semantic`| ✅ | ❌ | ❌ | ❌ | ✅ | ✅ |
<sup>1</sup> `queryType=semantic` can't support explicit `simple` or `full` values because the `queryType` parameter is being used for `semantic`. The effective query behaviors are the defaults of the simple parser.
72
75
73
-
<sup>1</sup> `semanticQuery` isn't supported in the portal [search explorer](search-explorer.md).
76
+
<sup>2</sup> The `semanticQuery`parameter can be used for all query types. However, it isn't supported in the portal [Search Explorer](search-explorer.md).
74
77
75
78
Regardless of the parameter chosen, the index should contain text fields with rich semantic content and a [semantic configuration](semantic-how-to-configure.md).
76
79
77
80
### [**Azure portal**](#tab/portal-query)
78
81
79
-
[Search explorer](search-explorer.md) includes options for semantic ranking.
82
+
[Search explorer](search-explorer.md) includes options for semantic ranking. Recall that you can't set the `semanticQuery` parameter in the Azure portal.
80
83
81
84
1. Sign in to the [Azure portal](https://portal.azure.com).
82
85
@@ -114,7 +117,9 @@ Use [Search Documents](/rest/api/searchservice/documents/search-post) to formula
114
117
115
118
A response includes an `@search.rerankerScore` automatically. If you want captions or answers in the response, enable semantic ranking by setting `queryType` to `semantic` or setting `semanticQuery` and adding captions and answers to the request.
116
119
117
-
The following example in this section uses the [hotels-sample-index](search-get-started-portal.md) to demonstrate semantic ranking with semantic answers and captions.
120
+
The following examples in this section use the [hotels-sample-index](search-get-started-portal.md) to demonstrate semantic ranking with semantic answers and captions.
121
+
122
+
#### Use queryType=semantic
118
123
119
124
If you want to set `queryType` to `semantic`, paste the following request into a web client as a template. Replace `search-service-name` with your search service name and replace `hotels-sample-index` if you have a different index name.
120
125
@@ -155,7 +160,11 @@ POST https://[search-service-name].search.windows.net/indexes/hotels-sample-inde
155
160
156
161
1. Send the request to execute the query and return results.
157
162
158
-
If you want to use "semanticQuery" in order to use [vector search](vector-search-overview.md), [simple text syntax](query-simple-syntax.md), or [full text syntax](query-lucene-syntax.md), adjust your request to the following JSON:
163
+
#### Use semanticQuery
164
+
165
+
By using `semanticQuery`, you can explicitly apply [simple text syntax](query-simple-syntax.md) or [full text syntax](query-lucene-syntax.md), which means you can now do fielded search, term boosting, and proximity search. You can also specify a [pure vector query](vector-search-how-to-query.md) instead of just hybrid.
166
+
167
+
Adjust your request to the following JSON to use `semanticQuery`.
159
168
160
169
```http
161
170
POST https://[search-service-name].search.windows.net/indexes/hotels-sample-index/docs/search?api-version=2024-07-01
@@ -171,12 +180,11 @@ POST https://[search-service-name].search.windows.net/indexes/hotels-sample-inde
1. Set `queryType` to the search syntax you're using, either [simple](query-simple-syntax.md) or [full](query-lucene-syntax.md).
177
186
178
-
1. Set `semanticQuery` to the simple plain text query you want to use for semantic ranking. Empty queries aren't supported.
179
-
187
+
1. Set `semanticQuery` to the simple plain text query you want to use for semantic ranking. Empty queries aren't supported. Avoid operators or any query syntax inside the string itself.
0 commit comments