QuestionQ71

VerifiedDevelop AI solutions by using Azure data management services

A semantic-search application queries Azure Database for PostgreSQL and stores document embeddings and metadata in a table with these columns:

  • embedding (pgvector)
  • department
  • created_at

The application must return the five documents most similar to a supplied query embedding, limited to the finance department.

Implement semantic retrieval with metadata filtering. Select the query components that meet each requirement. Each component may be used once, more than once, or not at all.

Drag & Drop
Filter rows to finance.
Rank by similarity and return the top five.
Explanation

An equality filter on department restricts the result set to the Finance metadata value. In pgvector, <=> calculates cosine distance, so ascending ORDER BY embedding <=> :query_embedding ranks nearest (most similar) vectors first; LIMIT 5 returns five results. created_at DESC ranks by recency instead of similarity.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!