Home / Function/ test_qdrant_similarity_search_with_relevance_score_with_threshold_and_filter() — langchain Function Reference

test_qdrant_similarity_search_with_relevance_score_with_threshold_and_filter() — langchain Function Reference

Architecture documentation for the test_qdrant_similarity_search_with_relevance_score_with_threshold_and_filter() function in test_similarity_search.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  8d83993f_80de_770b_37ec_5b2f9f23ed52["test_qdrant_similarity_search_with_relevance_score_with_threshold_and_filter()"]
  5b7f0668_b386_695d_06c0_77020a3462af["test_similarity_search.py"]
  8d83993f_80de_770b_37ec_5b2f9f23ed52 -->|defined in| 5b7f0668_b386_695d_06c0_77020a3462af
  style 8d83993f_80de_770b_37ec_5b2f9f23ed52 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/qdrant/tests/integration_tests/test_similarity_search.py lines 182–209

def test_qdrant_similarity_search_with_relevance_score_with_threshold_and_filter(
    vector_name: str | None,
) -> 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 = Qdrant.from_texts(
        texts,
        ConsistentFakeEmbeddings(),
        metadatas=metadatas,
        location=":memory:",
        vector_name=vector_name,
    )
    score_threshold = 0.99  # for almost exact match
    # test negative filter condition
    negative_filter = {"page": 1, "metadata": {"page": 2, "pages": [3]}}
    kwargs = {"filter": negative_filter, "score_threshold": score_threshold}
    output = docsearch.similarity_search_with_relevance_scores("foo", k=3, **kwargs)
    assert len(output) == 0
    # test positive filter condition
    positive_filter = {"page": 0, "metadata": {"page": 1, "pages": [2]}}
    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

Frequently Asked Questions

What does test_qdrant_similarity_search_with_relevance_score_with_threshold_and_filter() do?
test_qdrant_similarity_search_with_relevance_score_with_threshold_and_filter() is a function in the langchain codebase, defined in libs/partners/qdrant/tests/integration_tests/test_similarity_search.py.
Where is test_qdrant_similarity_search_with_relevance_score_with_threshold_and_filter() defined?
test_qdrant_similarity_search_with_relevance_score_with_threshold_and_filter() is defined in libs/partners/qdrant/tests/integration_tests/test_similarity_search.py at line 182.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free