Skip to content

Commit dea1219

Browse files
Merge pull request #1474 from HeidiSteen/heidist-ignite
reformat semantic query params
2 parents 0969976 + 11eba3e commit dea1219

File tree

1 file changed

+23
-15
lines changed

1 file changed

+23
-15
lines changed

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

Lines changed: 23 additions & 15 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: how-to
13-
ms.date: 09/24/2024
13+
ms.date: 11/19/2024
1414
---
1515

1616
# Add semantic ranking to queries in Azure AI Search
@@ -51,8 +51,11 @@ A few query capabilities bypass relevance scoring, which makes them incompatible
5151

5252
## Set up the query
5353

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.
5555

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+
<!--
5659
1. Set `queryType` to `semantic`:
5760
+ [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.
5861
+ [Hybrid search](hybrid-search-overview.md).
@@ -61,22 +64,22 @@ By default, queries don't use semantic ranking. To use semantic ranking, two dif
6164
+ [Text search](search-lucene-query-architecture.md) using the [simple](query-simple-syntax.md) or [full](query-lucene-syntax.md) syntax.
6265
+ [Vector search](vector-search-overview.md).
6366
+ [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. -->
6768

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 |
6970
|-|-|-|-|-|-|-|
70-
| Set `queryType` to `semantic` |||||||
71-
| Set `semanticQuery`<sup>1</sup> |||||||
71+
| `queryType-semantic` <sup>1</sup> |||||||
72+
| `semanticQuery="<your plain text query>"`<sup>2</sup> |||||||
73+
74+
<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.
7275

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).
7477

7578
Regardless of the parameter chosen, the index should contain text fields with rich semantic content and a [semantic configuration](semantic-how-to-configure.md).
7679

7780
### [**Azure portal**](#tab/portal-query)
7881

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.
8083

8184
1. Sign in to the [Azure portal](https://portal.azure.com).
8285

@@ -114,7 +117,9 @@ Use [Search Documents](/rest/api/searchservice/documents/search-post) to formula
114117

115118
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.
116119

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
118123

119124
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.
120125

@@ -155,7 +160,11 @@ POST https://[search-service-name].search.windows.net/indexes/hotels-sample-inde
155160

156161
1. Send the request to execute the query and return results.
157162

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`.
159168

160169
```http
161170
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
171180
"highlightPostTag": "</strong>",
172181
"select": "HotelId,HotelName,Description,Category"
173182
}
174-
```
183+
```
175184

176185
1. Set `queryType` to the search syntax you're using, either [simple](query-simple-syntax.md) or [full](query-lucene-syntax.md).
177186

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.
180188

181189
### [**.NET SDK**](#tab/dotnet-query)
182190

0 commit comments

Comments
 (0)