AzureAISearchBM25Retriever
Retrieve documents from an Azure AI Search document store using BM25 retrieval.
Basic Information
- Type:
haystack_integrations.components.retrievers.azure_ai_search.bm25_retriever.AzureAISearchBM25Retriever - Components it can connect with:
- Receives queries and returns relevant documents.
Ranker:AzureAISearchBM25Retrieversends retrieved documents to aRankerfor reranking.
Inputs
| Parameter | Type | Default | Description |
|---|---|---|---|
| query | str | Text of the query. | |
| filters | Optional[Dict[str, Any]] | None | Filters applied to the retrieved documents. The way runtime filters are applied depends on the filter_policy chosen at retriever initialization. |
| top_k | Optional[int] | None | The maximum number of documents to retrieve. |
Outputs
| Parameter | Type | Default | Description |
|---|---|---|---|
| documents | List[Document] | A list of documents retrieved from the AzureAISearchDocumentStore. |
Overview
Use AzureAISearchBM25Retriever to retrieve documents from an Azure AI Search document store using BM25 (keyword-based) retrieval. This retriever must be connected to an AzureAISearchDocumentStore to run.
BM25 retrieval is useful when you want to find documents based on exact keyword matches rather than semantic similarity.
Azure AI Search Setup
To use this retriever, you need an Azure AI Search service with a properly configured index. For more information, see the Azure AI Search documentation.
Usage Example
Initializing the Component
components:
AzureAISearchBM25Retriever:
type: haystack_integrations.components.retrievers.azure_ai_search.bm25_retriever.AzureAISearchBM25Retriever
init_parameters:
document_store:
type: haystack_integrations.document_stores.azure_ai_search.document_store.AzureAISearchDocumentStore
init_parameters:
api_key:
type: env_var
env_vars:
- AZURE_SEARCH_API_KEY
strict: false
azure_endpoint:
type: env_var
env_vars:
- AZURE_SEARCH_ENDPOINT
strict: false
index_name: my-index
top_k: 10
Parameters
Init Parameters
These are the parameters you can configure in Pipeline Builder:
| Parameter | Type | Default | Description |
|---|---|---|---|
| document_store | AzureAISearchDocumentStore | An instance of AzureAISearchDocumentStore to use with the retriever. | |
| filters | Optional[Dict[str, Any]] | None | Filters applied when fetching documents from the document store. Filters are applied during the BM25 search to ensure the retriever returns top_k matching documents. |
| top_k | int | 10 | Maximum number of documents to return. |
| filter_policy | Union[str, FilterPolicy] | FilterPolicy.REPLACE | Policy to determine how filters are applied. Can be REPLACE (runtime filters replace initialization filters) or MERGE (runtime filters are merged with initialization filters). |
| query_type | Optional[str] | None | A string indicating the type of query to perform. Possible values are simple, full, and semantic. |
| semantic_configuration_name | Optional[str] | None | The name of semantic configuration to be used when processing semantic queries. |
Run Method Parameters
These are the parameters you can configure for the component's run() method. You can pass these parameters at query time through the API, in Playground, or when running a job.
| Parameter | Type | Default | Description |
|---|---|---|---|
| query | str | Text of the query. | |
| filters | Optional[Dict[str, Any]] | None | Filters applied to the retrieved documents. The way runtime filters are applied depends on the filter_policy chosen at retriever initialization. |
| top_k | Optional[int] | None | The maximum number of documents to retrieve. |
Was this page helpful?