diff --git a/.code-samples.meilisearch.yaml b/.code-samples.meilisearch.yaml index 02409739..4e1a1949 100644 --- a/.code-samples.meilisearch.yaml +++ b/.code-samples.meilisearch.yaml @@ -730,3 +730,5 @@ update_proximity_precision_settings_1: |- client.index('books').update_proximity_precision(ProximityPrecision.BY_ATTRIBUTE) reset_proximity_precision_settings_1: |- client.index('books').reset_proximity_precision() +search_parameter_reference_ranking_score_threshold_1: |- + client.index('INDEX_NAME').search('badman', { 'rankingScoreThreshold': 0.2 }) diff --git a/tests/index/test_index_search_meilisearch.py b/tests/index/test_index_search_meilisearch.py index e41415d1..ddf56e60 100644 --- a/tests/index/test_index_search_meilisearch.py +++ b/tests/index/test_index_search_meilisearch.py @@ -518,3 +518,19 @@ def test_search_distinct(index_with_documents): assert len(response["hits"]) == 11 assert genres == {None: 9, "action": 1, "Sci Fi": 1} assert response["hits"][0]["id"] == "399579" + + +@pytest.mark.parametrize( + "query, ranking_score_threshold, expected", + ( + ("Husband and wife", 1, 0), + ("Husband and wife", 0.9, 1), + ("wife", 0.9, 0), + ("wife", 0.5, 2), + ), +) +def test_search_ranking_threshold(query, ranking_score_threshold, expected, index_with_documents): + response = index_with_documents().search( + query, {"rankingScoreThreshold": ranking_score_threshold} + ) + assert len(response["hits"]) == expected