Skip to content

Commit bbc0907

Browse files
Merge #965
965: Add tests and docs about showRankingScoreDetails r=sanders41 a=the-sinner # Pull Request ## Related issue Fixes #939 ## What does this PR do? - Add tests and docs about showRankingScoreDetails ## 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 da08f26 + baeb766 commit bbc0907

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

.code-samples.meilisearch.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,10 @@ search_parameter_guide_show_ranking_score_1: |-
360360
client.index('movies').search('dragon', {
361361
'showRankingScore': true
362362
})
363+
search_parameter_guide_show_ranking_score_details_1: |-
364+
client.index('movies').search('dragon', {
365+
'showRankingScoreDetails': True
366+
})
363367
search_parameter_guide_attributes_to_search_on_1: |-
364368
client.index('movies').search('adventure', {
365369
'attributesToSearchOn': ['overview']

tests/index/test_index_search_meilisearch.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,20 @@ def test_attributes_to_search_on_search_no_match(index_with_documents):
459459
assert response["hits"] == []
460460

461461

462+
def test_show_ranking_score_details(index_with_documents):
463+
"""Tests search with show ranking score details"""
464+
response = index_with_documents().search(
465+
"man loves",
466+
{"showRankingScoreDetails": True},
467+
)
468+
469+
assert isinstance(response, dict)
470+
assert len(response["hits"]) > 1
471+
assert response["hits"][0]["_rankingScoreDetails"] is not None
472+
assert response["hits"][0]["_rankingScoreDetails"]["words"] is not None
473+
assert response["hits"][0]["_rankingScoreDetails"]["words"]["score"] == 1
474+
475+
462476
@pytest.mark.usefixtures("enable_vector_search")
463477
def test_vector_search(index_with_documents_and_vectors):
464478
response = index_with_documents_and_vectors().search(

0 commit comments

Comments
 (0)