Launch price: every exam for $29.99 a year, for the first 300 buyers. See the price

CertStreak
Menu

Implement and optimize hybrid search approaches combining semantic and keyword-based retrieval

A worked example

Complete the statement

A support team stores tickets in a Cosmos DB in Fabric container. Each document holds a vector embedding in the embedding property and the ticket text in the body property. The container's indexing policy includes a vector index on /embedding and a full-text index on /body.

A RAG application must return the 5 most relevant tickets. It must rank them by merging semantic similarity to the parameter @queryVector with BM25 keyword relevance for the terms "printer" and "offline", and it must use Reciprocal Rank Fusion to do so.

How should you complete the query?

SELECT TOP 5 * FROM container c ORDER BY RRF(VECTORDISTANCE(c.embedding, @queryVector), (c.body, "printer", "offline"))

  • Blank 1: RANK (correct answer)

    RANK is correct: hybrid queries call RRF inside an ORDER BY RANK clause. DESC and ASC are sort-direction keywords. They do not introduce a rank-fusion expression such as RRF.

  • Blank 2: FULLTEXTSCORE (correct answer)

    FULLTEXTSCORE supplies the BM25 keyword component. RRF combines component rankings rather than calculating keyword relevance from text and search terms. VECTORDISTANCE measures vector similarity rather than BM25 keyword relevance.

Why

Cosmos DB in Fabric runs hybrid search by placing the RRF system function in an ORDER BY RANK clause. That clause combines a VECTORDISTANCE component for semantic similarity with a FULLTEXTSCORE component for BM25 keyword scoring. RRF then merges the two rankings into one unified ranking, and TOP 5 limits the output to the five best results.

Practise this topic until it's automatic.

Ten questions a day, every answer explained, and misses that come back until you beat them.

Start free