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/hybrid-search-how-to-query.md
+26-14Lines changed: 26 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,46 +9,55 @@ ms.service: cognitive-search
9
9
ms.custom:
10
10
- ignite-2023
11
11
ms.topic: how-to
12
-
ms.date: 08/05/2024
12
+
ms.date: 10/01/2024
13
13
---
14
14
15
15
# Create a hybrid query in Azure AI Search
16
16
17
-
[Hybrid search](hybrid-search-overview.md) combines one or more text (keyword) queries with one or more vector queries in a single search request. The queries execute in parallel. The results are merged and reordered by new search scores, using [Reciprocal Rank Fusion (RRF)](hybrid-search-ranking.md) to return a unified result set.
17
+
[Hybrid search](hybrid-search-overview.md) combines text (keyword) and vector queries in a single search request. All subqueries in the request execute in parallel. The results are merged and reordered by new search scores, using [Reciprocal Rank Fusion (RRF)](hybrid-search-ranking.md) to return a unified result set. In many cases, [per benchmark tests](https://techcommunity.microsoft.com/t5/ai-azure-ai-services-blog/azure-ai-search-outperforming-vector-search-with-hybrid/ba-p/3929167), hybrid queries with semantic ranking return the most relevant results.
18
18
19
-
In many cases, [per benchmark tests](https://techcommunity.microsoft.com/t5/ai-azure-ai-services-blog/azure-ai-search-outperforming-vector-search-with-hybrid/ba-p/3929167), hybrid queries with semantic ranking return the most relevant results.
19
+
In this article, learn how to:
20
20
21
-
To improve relevance, use these parameters:
21
+
+ Set up a basic request
22
+
+ Add filters
23
+
+ Improve relevance using semantic ranking or vector weights
24
+
+ Optimize query behaviors by controlling text and vector inputs
25
+
26
+
To improve relevance in a hybrid query, use these parameters:
22
27
23
28
+[vector.queries.weight](vector-search-how-to-query.md#vector-weighting) lets you set the relative weight of the vector query. This feature is particularly useful in complex queries where two or more distinct result sets need to be combined, as is the case for hybrid search. This feature is generally available.
24
29
25
30
+[hybridsearch.maxTextRecallSize and countAndFacetMode (preview)](#set-maxtextrecallsize-and-countandfacetmode-preview) give you more control over text inputs into a hybrid query. This feature requires a preview API version.
26
31
27
32
## Prerequisites
28
33
29
-
+ A search index containing `searchable` vector and nonvector fields. See[Create an index](search-how-to-create-search-index.md) and [Add vector fields to a search index](vector-search-how-to-create-index.md).
34
+
+ A search index containing `searchable` vector and nonvector fields. We recommend the [Import and vectorize data wizard](search-import-data-portal.md) to create an index quickly. Otherwise, see[Create an index](search-how-to-create-search-index.md) and [Add vector fields to a search index](vector-search-how-to-create-index.md).
30
35
31
36
+ (Optional) If you want the [semantic ranker](semantic-search-overview.md), your search service must be Basic tier or higher, with [semantic ranker enabled](semantic-how-to-enable-disable.md).
32
37
33
-
+ (Optional) If you want text-to-vector conversion of a query string, [create and assign a vectorizer](vector-search-how-to-configure-vectorizer.md) to vector fields in the search index.
38
+
+ (Optional) If you want built-in text-to-vector conversion of a query string, [create and assign a vectorizer](vector-search-how-to-configure-vectorizer.md) to vector fields in the search index.
34
39
35
40
## Choose an API or tool
36
41
37
-
+[**2024-07-01**](/rest/api/searchservice/documents/search-post) stable version or a recent preview API version if you're using [maxTextRecallSize and countAndFacetMode(preview)](#set-maxtextrecallsize-and-countandfacetmode-preview).
38
-
+ Search Explorer in the Azure portal (targets 2024-05-01-preview behaviors)
39
-
+ Newer stable or beta packages of the Azure SDKs (see change logs for SDK feature support)
42
+
+ Search Explorer in the Azure portal (supports both stable and preview API search syntax) has a JSON view that lets you paste in a hybrid request.
43
+
44
+
+[**2024-07-01**](/rest/api/searchservice/documents/search-post) stable version or a recent preview API version if you're using preview features like [maxTextRecallSize and countAndFacetMode(preview)](#set-maxtextrecallsize-and-countandfacetmode-preview).
45
+
46
+
For readability, we use REST examples to explain how the APIs work. You can use a REST client like Visual Studio Code with the REST extension to build hybrid queries. For more information, see [Quickstart: Vector search using REST APIs](search-get-started-vector.md).
40
47
41
-
## Run a hybrid query in Search Explorer
48
+
+ Newer stable or beta packages of the Azure SDKs (see change logs for SDK feature support).
42
49
43
-
1. In [Search Explorer](search-explorer.md), make sure the API version is **2024-07-01** or newer preview API versions.
50
+
## Set up a hybrid query in Search Explorer
44
51
45
-
1.Under **View**, select **JSON view**.
52
+
1.In [Search Explorer](search-explorer.md), make sure the API version is **2024-07-01** or a newer preview API version.
46
53
47
-
1. Replace the default query template with a hybrid query, such as the one starting on line 539 for the [vector quickstart example](vector-search-how-to-configure-vectorizer.md#try-a-vectorizer-with-sample-data). For brevity, the vector is truncated in this article.
54
+
1. Under **View**, select **JSON view** so that you can paste in a vector query.
55
+
56
+
1. Replace the default query template with a hybrid query, such as the "Run a hybrid query" example starting on line 539 in the [vector quickstart](https://raw.githubusercontent.com/Azure-Samples/azure-search-rest-samples/refs/heads/main/Quickstart-vectors/az-search-vector-quickstart.rest). For brevity, the vector is truncated in this article.
48
57
49
58
A hybrid query has a text query specified in `search`, and a vector query specified under `vectorQueries.vector`.
50
59
51
-
The text query and vector query should be equivalent or at least not conflict. If the queries are different, you don't get the benefit of hybrid.
60
+
The text query and vector query can be equivalent or divergent, but it's common for them to share the same intent.
52
61
53
62
```json
54
63
{
@@ -70,6 +79,9 @@ To improve relevance, use these parameters:
70
79
71
80
1. Select **Search**.
72
81
82
+
> [!TIP]
83
+
> Search results are easier to read if you hide the vectors. In **Query Options**, turn on **Hide vector values in search results**.
84
+
73
85
## Hybrid query request (REST API)
74
86
75
87
A hybrid query combines text search and vector search, where the `search` parameter takes a query string and `vectorQueries.vector` takes the vector query. The search engine runs full text and vector queries in parallel. The union of all matches is evaluated for relevance using Reciprocal Rank Fusion (RRF) and a single result set is returned in the response.
Copy file name to clipboardExpand all lines: articles/search/hybrid-search-overview.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,12 +9,12 @@ ms.service: cognitive-search
9
9
ms.custom:
10
10
- ignite-2023
11
11
ms.topic: conceptual
12
-
ms.date: 08/19/2024
12
+
ms.date: 10/01/2024
13
13
---
14
14
15
15
# Hybrid search using vectors and full text in Azure AI Search
16
16
17
-
Hybrid search is a combination of full text and vector queries that execute against a search index that contains both searchable plain text content and generated embeddings. For query purposes, hybrid search is:
17
+
Hybrid search is a combination of full text and vector queries that execute against a search index containing both searchable plain text content and generated embeddings. For query purposes, hybrid search is:
18
18
19
19
+ A single query request that includes both `search` and `vectors` query parameters
20
20
+ Executing in parallel
@@ -26,13 +26,13 @@ This article explains the concepts, benefits, and limitations of hybrid search.
26
26
27
27
In Azure AI Search, vector fields containing embeddings can live alongside textual and numerical fields, allowing you to formulate hybrid queries that execute in parallel. Hybrid queries can take advantage of existing functionality like filtering, faceting, sorting, scoring profiles, and [semantic ranking](semantic-search-overview.md) in a single search request.
28
28
29
-
Hybrid search combines results from both full text and vector queries, which use different ranking functions such as BM25and HNSW. A [Reciprocal Rank Fusion (RRF)](hybrid-search-ranking.md) algorithm merges the results. The query response provides just one result set, using RRF to pick the most relevant matches from each query.
29
+
Hybrid search combines results from both full text and vector queries, which use different ranking functions such as BM25, HNSW, and EKNN. A [Reciprocal Rank Fusion (RRF)](hybrid-search-ranking.md) algorithm merges the results. The query response provides just one result set, using RRF to rank the unified results.
30
30
31
31
## Structure of a hybrid query
32
32
33
-
Hybrid search is predicated on having a search index that contains fields of various [data types](/rest/api/searchservice/supported-data-types), including plain text and numbers, geo coordinates for geospatial search, and vectors for a mathematical representation of a chunk of text. You can use almost all query capabilities in Azure AI Search with a vector query, except for client-side interactions such as autocomplete and suggestions.
33
+
Hybrid search is predicated on having a search index that contains fields of various [data types](/rest/api/searchservice/supported-data-types), including plain text and numbers, geo coordinates if you want geospatial search, and vectors for a mathematical representation of a chunk of text. You can use almost all query capabilities in Azure AI Search with a vector query, except for pure text client-side interactions such as autocomplete and suggestions.
34
34
35
-
A representative hybrid query might be as follows (notice the vector is trimmed for brevity):
35
+
A representative hybrid query might be as follows (notice that the vector queries have placeholder values for brevity):
36
36
37
37
```http
38
38
POST https://{{searchServiceName}}.search.windows.net/indexes/hotels-vector-quickstart/docs/search?api-version=2024-07-01
@@ -63,9 +63,9 @@ POST https://{{searchServiceName}}.search.windows.net/indexes/hotels-vector-quic
63
63
64
64
Key points include:
65
65
66
-
+`search` specifies a full text search query.
66
+
+`search` specifies a single full text search query.
67
67
+`vectors` for vector queries, which can be multiple, targeting multiple vector fields. If the embedding space includes multi-lingual content, vector queries can find the match with no language analyzers or translation required.
68
-
+`select` specifies which fields to return in results, which can be text fields that are human readable.
68
+
+`select` specifies which fields to return in results, which should be text fields that are human readable.
69
69
+`filters` can specify geospatial search or other include and exclude criteria, such as whether parking is included. The geospatial query in this example finds hotels within a 300-kilometer radius of Washington D.C.
70
70
+`facets` can be used to compute facet buckets over results that are returned from hybrid queries.
71
71
+`queryType=semantic` invokes semantic ranker, applying machine reading comprehension to surface more relevant search results. Semantic ranking is optional. If you aren't using that feature, remove the last three lines of the hybrid query.
0 commit comments