Instruction 02
Exploring How Azure AI Search performs Hybrid Search
In Azure AI Search, the query for a hybrid search contains both search and vectors parameters. The query is converted to a hybrid query, allowing both types of searches to be executed in parallel. Their results are combined, reranked using Reciprocal Rank Fusion (RRF), and returned quickly and efficiently. Ultimately, you get the best of both worlds in a single search operation.
Hybrid queries in Azure AI Search inherit some useful features from vector search, such as filtering and reranking. Currently, only autocomplete and suggestions features from vector search are unavailable in the API for a hybrid search.
Using your source data from the previous lesson, here’s how a hybrid query could look:
{
"count": true,
"search": "psychological thriller exploring technology's impact on society",
"filters": [
"category eq 'Thriller' and id eq '50'"
],
"facets": [
"category"
],
"select": [
"id",
"title",
"content",
"category"
],
"queryType": "full",
"queryLanguage": "en-us",
"semanticConfiguration": "default",
"vectors": [
{
"value": [ <array of embeddings> ],
"k": 7,
"fields": "DescriptionVector"
},
{
"value": [ <array of embeddings> ],
"k": 7,
"fields": "Description_frVector"
}
]
}
Here’s a breakdown of the key fields:
-
search: Holds the search query used to perform both full-text and semantic/vector searches. -
select: Restricts the results to specific fields. -
filters: Further restricts the results based on specified criteria (in this case, category and ID). -
facets: Allows users to filter results by category, providing additional filtering to focus the search, improve speed, and produce more relevant results. -
vectors: An array of embeddings of thesearchquery used for vector search. -
queryType: Specifies the type of query to use (in this case,fullindicates semantic search). This enables semantic search and is used withqueryLanguageandsemanticConfigurationto configure it fully. -
queryLanguage: Specifies the language for the search. -
semanticConfiguration: Refers to the default semantic configuration. You can specify another configuration by name.
When using the APIs or SDKs, these details are abstracted away. Azure AI Search provides sensible defaults for the objects and configurations you’ll create to perform the hybrid search.