Setup
You’ll first need to install the@azure/search-documents
SDK and the @langchain/community
package:
npm
.env vars
About hybrid search
Hybrid search is a feature that combines the strengths of full text search and vector search to provide the best ranking performance. It’s enabled by default in Azure AI Search vector stores, but you can select a different search query type by setting thesearch.type
property when creating the vector store.
You can read more about hybrid search and how it may improve your search results in the official documentation.
In some scenarios like retrieval-augmented generation (RAG), you may want to enable semantic ranking in addition to hybrid search to improve the relevance of the search results. You can enable semantic ranking by setting the search.type
property to AzureAISearchQueryType.SemanticHybrid
when creating the vector store.
Note that semantic ranking capabilities are only available in the Basic and higher pricing tiers, and subject to regional availability.
You can read more about the performance of using semantic ranking with hybrid search in this blog post.
Example: index docs, vector search and LLM integration
Below is an example that indexes documents from a file in Azure AI Search, runs a hybrid search query, and finally uses a chain to answer a question in natural language based on the retrieved documents.Related
- Vector store conceptual guide
- Vector store how-to guides