Introduction
Semantic search augments standard keyword search by using semantic similarity rather than exact word matches. Instead of relying on overlapping terms, it uses embedding vectors generated by AI models to measure how similar a query and a document are in meaning. In this module, you enable semantic search in Azure Database for PostgreSQL flexible server by combining the pgvector and azure_ai extensions with Azure OpenAI embeddings so that a query like "sunny" can match descriptions such as "bright natural light" even when the words don’t match exactly. You work with a vacation property listings scenario to see how semantic search can deliver more relevant results with less manual keyword tuning.
Imagine you work on the Margie’s Travel team, building web, and mobile apps that help travelers find vacation rental properties. Today, your search relies on simple keywords like "pool" or "pet-friendly," which often miss great listings because the wording in descriptions doesn’t match the user’s query. You want to deliver more relevant results without constantly curating keyword lists. In this module, you use the Margie’s Travel property listings to see how enabling semantic search in Azure Database for PostgreSQL can surface the right properties based on meaning, not just exact words.
By the end of this module, you're able to:
- Describe how semantic search differs from traditional keyword search and why embeddings improve result relevance.
- Enable the
pgvectorandazure_aiextensions on an Azure Database for PostgreSQL flexible server instance. - Use Azure OpenAI, through the
azure_aiextension, to generate and store vector embeddings for text data. - Execute semantic search queries over vector columns in PostgreSQL using Azure OpenAI embeddings.
- Implement a search function that accepts a query string, generates an embedding for the query, and runs a semantic search against vacation property listings.