Skip to content

Commit 3c75256

Browse files
committed
adds integration test
1 parent cca3dac commit 3c75256

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

.code-samples.meilisearch.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,4 +731,4 @@ update_proximity_precision_settings_1: |-
731731
reset_proximity_precision_settings_1: |-
732732
client.index('books').reset_proximity_precision()
733733
search_parameter_reference_ranking_score_threshold_1: |-
734-
client.index('INDEX_NAME').search('badman', { rankingScoreThreshold: 0.2 })
734+
client.index('INDEX_NAME').search('badman', { 'rankingScoreThreshold': 0.2 })

tests/index/test_index_search_meilisearch.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,3 +518,18 @@ def test_search_distinct(index_with_documents):
518518
assert len(response["hits"]) == 11
519519
assert genres == {None: 9, "action": 1, "Sci Fi": 1}
520520
assert response["hits"][0]["id"] == "399579"
521+
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

0 commit comments

Comments
 (0)