Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supports rankingScoreThreshold search parameter #1008

Merged
merged 5 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
aweidner marked this conversation as resolved.
Show resolved Hide resolved
15 changes: 15 additions & 0 deletions tests/index/test_index_search_meilisearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,3 +518,18 @@ 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"


def test_search_ranking_threshold(index_with_documents):
# No documents matched with exact phrase and ranking threshold 1
response = index_with_documents().search("Husband and wife", {"rankingScoreThreshold": 1})
assert len(response["hits"]) == 0
# Only one document contains this phrase
response = index_with_documents().search("Husband and wife", {"rankingScoreThreshold": 0.9})
assert len(response["hits"]) == 1
# No documents matched with too high of a threshold for this term
response = index_with_documents().search("wife", {"rankingScoreThreshold": 0.9})
assert len(response["hits"]) == 0
# Two documents do contain the term but they only match at a lower threshold
response = index_with_documents().search("wife", {"rankingScoreThreshold": 0.5})
assert len(response["hits"]) == 2
sanders41 marked this conversation as resolved.
Show resolved Hide resolved
Loading