@@ -520,16 +520,17 @@ def test_search_distinct(index_with_documents):
520
520
assert response ["hits" ][0 ]["id" ] == "399579"
521
521
522
522
523
- def test_search_ranking_threshold (index_with_documents ):
524
- # No documents matched with exact phrase and ranking threshold 1
525
- response = index_with_documents ().search ("Husband and wife" , {"rankingScoreThreshold" : 1 })
526
- assert len (response ["hits" ]) == 0
527
- # Only one document contains this phrase
528
- response = index_with_documents ().search ("Husband and wife" , {"rankingScoreThreshold" : 0.9 })
529
- assert len (response ["hits" ]) == 1
530
- # No documents matched with too high of a threshold for this term
531
- response = index_with_documents ().search ("wife" , {"rankingScoreThreshold" : 0.9 })
532
- assert len (response ["hits" ]) == 0
533
- # Two documents do contain the term but they only match at a lower threshold
534
- response = index_with_documents ().search ("wife" , {"rankingScoreThreshold" : 0.5 })
535
- assert len (response ["hits" ]) == 2
523
+ @pytest .mark .parametrize (
524
+ "query, ranking_score_threshold, expected" ,
525
+ (
526
+ ("Husband and wife" , 1 , 0 ),
527
+ ("Husband and wife" , 0.9 , 1 ),
528
+ ("wife" , 0.9 , 0 ),
529
+ ("wife" , 0.5 , 2 ),
530
+ ),
531
+ )
532
+ def test_search_ranking_threshold (query , ranking_score_threshold , expected , index_with_documents ):
533
+ response = index_with_documents ().search (
534
+ query , {"rankingScoreThreshold" : ranking_score_threshold }
535
+ )
536
+ assert len (response ["hits" ]) == expected
0 commit comments