Skip to content

Commit 7dbade5

Browse files
Merge #1008
1008: Supports `rankingScoreThreshold` search parameter r=sanders41 a=aweidner # Pull Request ## Related issue Fixes #986 ## What does this PR do? - Adds an integration test for a search using `rankingScoreThreshold` - Updates the code example file to include a translated call for search involving `rankingScoreThreshold` ## PR checklist Please check if your PR fulfills the following requirements: - [x] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)? - [x] Have you read the contributing guidelines? - [x] Have you made sure that the title is accurate and descriptive of the changes? Thank you so much for contributing to Meilisearch! Co-authored-by: Adam Weidner <[email protected]> Co-authored-by: Adam Weidner <[email protected]>
2 parents b555bc1 + 2bab760 commit 7dbade5

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

.code-samples.meilisearch.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,3 +730,5 @@ update_proximity_precision_settings_1: |-
730730
client.index('books').update_proximity_precision(ProximityPrecision.BY_ATTRIBUTE)
731731
reset_proximity_precision_settings_1: |-
732732
client.index('books').reset_proximity_precision()
733+
search_parameter_reference_ranking_score_threshold_1: |-
734+
client.index('INDEX_NAME').search('badman', { 'rankingScoreThreshold': 0.2 })

tests/index/test_index_search_meilisearch.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,3 +518,19 @@ 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+
@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

Comments
 (0)