hybrid_search() — langchain Function Reference
Architecture documentation for the hybrid_search() function in vectorstores.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD eab54379_c553_ad20_cd24_933c0ff0a730["hybrid_search()"] babbef04_3a0c_25f4_58a8_9d3209d5867e["Chroma"] eab54379_c553_ad20_cd24_933c0ff0a730 -->|defined in| babbef04_3a0c_25f4_58a8_9d3209d5867e style eab54379_c553_ad20_cd24_933c0ff0a730 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/chroma/langchain_chroma/vectorstores.py lines 684–728
def hybrid_search(self, search: Search) -> list[Document]:
"""Run hybrid search with Chroma.
Args:
search: The Search configuration for hybrid search.
Returns:
A list of documents resulting from the search operation.
Example:
from chromadb import Search, K, Knn, Rrf
# Create RRF ranking with text query
hybrid_rank = Rrf(
ranks=[
Knn(query="query", return_rank=True, limit=300),
Knn(query="query learning applications", key="sparse_embedding")
],
weights=[2.0, 1.0], # Dense 2x more important
k=60
)
# Build complete the search strategy
search = (Search()
.where(
(K("language") == "en") &
(K("year") >= 2020)
)
.rank(hybrid_rank)
.limit(10)
.select(K.DOCUMENT, K.SCORE, "title", "year")
)
results = vector_store.hybrid_search(search)
"""
results = self._collection.search(search)
return [
Document(
page_content=record["document"],
metadata=record["metadata"],
id=record["id"],
)
for record in results.rows()[0]
if record["document"] is not None
]
Domain
Subdomains
Source
Frequently Asked Questions
What does hybrid_search() do?
hybrid_search() is a function in the langchain codebase, defined in libs/partners/chroma/langchain_chroma/vectorstores.py.
Where is hybrid_search() defined?
hybrid_search() is defined in libs/partners/chroma/langchain_chroma/vectorstores.py at line 684.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free