test_relevance_search_with_threshold_and_filter() — langchain Function Reference
Architecture documentation for the test_relevance_search_with_threshold_and_filter() function in test_search.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 21045765_dbb0_cecd_c40a_6daa441dedac["test_relevance_search_with_threshold_and_filter()"] 7105a1c4_0f67_8c01_efc7_d00363a3ed66["test_search.py"] 21045765_dbb0_cecd_c40a_6daa441dedac -->|defined in| 7105a1c4_0f67_8c01_efc7_d00363a3ed66 style 21045765_dbb0_cecd_c40a_6daa441dedac fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/qdrant/tests/integration_tests/qdrant_vector_store/test_search.py lines 209–251
def test_relevance_search_with_threshold_and_filter(
location: str,
content_payload_key: str,
metadata_payload_key: str,
vector_name: str,
) -> None:
"""Test end to end construction and search."""
texts = ["foo", "bar", "baz"]
metadatas = [
{"page": i, "metadata": {"page": i + 1, "pages": [i + 2, -1]}}
for i in range(len(texts))
]
docsearch = QdrantVectorStore.from_texts(
texts,
ConsistentFakeEmbeddings(),
metadatas=metadatas,
location=location,
content_payload_key=content_payload_key,
metadata_payload_key=metadata_payload_key,
vector_name=vector_name,
)
score_threshold = 0.99 # for almost exact match
negative_filter = models.Filter(
must=[
models.FieldCondition(
key=f"{metadata_payload_key}.page", match=models.MatchValue(value=1)
)
]
)
kwargs = {"filter": negative_filter, "score_threshold": score_threshold}
output = docsearch.similarity_search_with_relevance_scores("foo", k=3, **kwargs)
assert len(output) == 0
positive_filter = models.Filter(
must=[
models.FieldCondition(
key=f"{metadata_payload_key}.page", match=models.MatchValue(value=0)
)
]
)
kwargs = {"filter": positive_filter, "score_threshold": score_threshold}
output = docsearch.similarity_search_with_relevance_scores("foo", k=3, **kwargs)
assert len(output) == 1
assert all(score >= score_threshold for _, score in output)
Domain
Subdomains
Source
Frequently Asked Questions
What does test_relevance_search_with_threshold_and_filter() do?
test_relevance_search_with_threshold_and_filter() is a function in the langchain codebase, defined in libs/partners/qdrant/tests/integration_tests/qdrant_vector_store/test_search.py.
Where is test_relevance_search_with_threshold_and_filter() defined?
test_relevance_search_with_threshold_and_filter() is defined in libs/partners/qdrant/tests/integration_tests/qdrant_vector_store/test_search.py at line 209.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free