Skip to content

Commit 8946d79

Browse files
Merge #966
966: Add tests for displaying ranking score in search hits r=sanders41 a=the-sinner # Pull Request ## Related issue Fixes #827 ## What does this PR do? - Add tests for displaying ranking score in search hits ## 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: Shalabh Agarwal <[email protected]>
2 parents bbc0907 + d2ae96b commit 8946d79

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

.code-samples.meilisearch.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ typo_tolerance_guide_4: |-
358358
})
359359
search_parameter_guide_show_ranking_score_1: |-
360360
client.index('movies').search('dragon', {
361-
'showRankingScore': true
361+
'showRankingScore': True
362362
})
363363
search_parameter_guide_show_ranking_score_details_1: |-
364364
client.index('movies').search('dragon', {

tests/index/test_index_search_meilisearch.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,19 @@ def test_show_ranking_score_details(index_with_documents):
473473
assert response["hits"][0]["_rankingScoreDetails"]["words"]["score"] == 1
474474

475475

476+
def test_show_ranking_score(index_with_documents):
477+
"""Tests search with show ranking score"""
478+
response = index_with_documents().search(
479+
"man loves",
480+
{"showRankingScore": True},
481+
)
482+
483+
assert isinstance(response, dict)
484+
assert len(response["hits"]) > 1
485+
assert response["hits"][0]["_rankingScore"] is not None
486+
assert response["hits"][0]["_rankingScore"] >= 0.9
487+
488+
476489
@pytest.mark.usefixtures("enable_vector_search")
477490
def test_vector_search(index_with_documents_and_vectors):
478491
response = index_with_documents_and_vectors().search(

0 commit comments

Comments
 (0)