Skip to main content

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: AzureAISearchBM25Retriever sends retrieved documents to a Ranker for reranking.

Inputs

ParameterTypeDefaultDescription
querystrText of the query.
filtersOptional[Dict[str, Any]]NoneFilters applied to the retrieved documents. The way runtime filters are applied depends on the filter_policy chosen at retriever initialization.
top_kOptional[int]NoneThe maximum number of documents to retrieve.

Outputs

ParameterTypeDefaultDescription
documentsList[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:

ParameterTypeDefaultDescription
document_storeAzureAISearchDocumentStoreAn instance of AzureAISearchDocumentStore to use with the retriever.
filtersOptional[Dict[str, Any]]NoneFilters 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_kint10Maximum number of documents to return.
filter_policyUnion[str, FilterPolicy]FilterPolicy.REPLACEPolicy to determine how filters are applied. Can be REPLACE (runtime filters replace initialization filters) or MERGE (runtime filters are merged with initialization filters).
query_typeOptional[str]NoneA string indicating the type of query to perform. Possible values are simple, full, and semantic.
semantic_configuration_nameOptional[str]NoneThe 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.

ParameterTypeDefaultDescription
querystrText of the query.
filtersOptional[Dict[str, Any]]NoneFilters applied to the retrieved documents. The way runtime filters are applied depends on the filter_policy chosen at retriever initialization.
top_kOptional[int]NoneThe maximum number of documents to retrieve.