Skip to content

The agent engineering platform.

fix: Set default search_type to 'similarity' in as_retriever method of AzureSearch (#28376)

TamagoTorisugi0f0df2df6039
diff --git a/libs/community/langchain_community/vectorstores/azuresearch.py b/libs/community/langchain_community/vectorstores/azuresearch.py
index 2a715b846f..6d19574e8c 100644
--- a/libs/community/langchain_community/vectorstores/azuresearch.py
+++ b/libs/community/langchain_community/vectorstores/azuresearch.py
@@ -1545,10 +1545,9 @@ class AzureSearch(VectorStore):
"""Return AzureSearchVectorStoreRetriever initialized from this VectorStore.
Args:
- search_type (Optional[str]): Defines the type of search that
- the Retriever should perform.
- Can be "similarity" (default), "hybrid", or
- "semantic_hybrid".
+ search_type (Optional[str]): Overrides the type of search that
+ the Retriever should perform. Defaults to `self.search_type`.
+ Can be "similarity", "hybrid", or "semantic_hybrid".
search_kwargs (Optional[Dict]): Keyword arguments to pass to the
search function. Can include things like:
score_threshold: Minimum relevance threshold
@@ -1561,6 +1560,9 @@ class AzureSearch(VectorStore):
Returns:
AzureSearchVectorStoreRetriever: Retriever class for VectorStore.
"""
+ search_type = kwargs.get("search_type", self.search_type)
+ kwargs["search_type"] = search_type
+
tags = kwargs.pop("tags", None) or []
tags.extend(self._get_retriever_tags())
return AzureSearchVectorStoreRetriever(vectorstore=self, **kwargs, tags=tags)