def test_semantic_search_with_near_duplicates(client: R2RClient):
    """Test semantic search can handle and differentiate near-duplicate
    content."""
    random_1 = str(uuid.uuid4())
    random_2 = str(uuid.uuid4())
    # Create two similar but distinct documents
    doc1 = client.documents.create(
        raw_text=
        f"Aristotle was a Greek philosopher who studied logic {random_1}."
    ).results.document_id
    doc2 = client.documents.create(
        raw_text=
        f"Aristotle, the Greek philosopher, studied formal logic {random_2}."
    ).results.document_id

    resp = client.retrieval.search(
        query="Tell me about Aristotle's work in logic",
        search_mode="custom",
        search_settings={
            "use_semantic_search": True,
            "limit": 25
        },
    )
    results = resp.results.chunk_search_results

    # Both documents should be returned but with different scores
    scores = [
        r.score for r in results
        if str(r.document_id) in [str(doc1), str(doc2)]
    ]
    assert len(scores) == 2, "Expected both similar documents"
    assert len(
        set(scores)) == 2, ("Expected different scores for similar documents")
Test semantic search can handle and differentiate near-duplicate
    content.
py/tests/integration/test_retrieval_advanced.py