Skip to content

Commit 805c05a

Browse files
Merge #528
528: Add new search param showRankingScoreDetails r=curquiza a=Tommy-42 # Pull Request ## Related issue Fixes #518 ## What does this PR do? - Add the search parameter `showRankingScoreDetails` introduced in [`Meilisearch v1.7.0`](https://github.com/meilisearch/meilisearch/releases/tag/v1.7.0) ## 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: Tommy PAGEARD <tommy.pageard@gmail.com>
2 parents 442b48e + 66755b4 commit 805c05a

File tree

5 files changed

+64
-25
lines changed

5 files changed

+64
-25
lines changed

.code-samples.meilisearch.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,10 @@ search_parameter_guide_show_ranking_score_1: |-
440440
resp, err := client.Index("movies").Search("dragon", &meilisearch.SearchRequest{
441441
showRankingScore: true,
442442
})
443+
search_parameter_guide_show_ranking_score_details_1: |-
444+
resp, err := client.Index("movies").Search("dragon", &meilisearch.SearchRequest{
445+
showRankingScoreDetails: true,
446+
})
443447
search_parameter_guide_matching_strategy_1: |-
444448
resp, err := client.Index("movies").Search("big fat liar", &meilisearch.SearchRequest{
445449
MatchingStrategy: "last",

index_search.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ func searchPostRequestParams(query string, request *SearchRequest) map[string]in
9696
if request.ShowRankingScore {
9797
params["showRankingScore"] = request.ShowRankingScore
9898
}
99+
if request.ShowRankingScoreDetails {
100+
params["showRankingScoreDetails"] = request.ShowRankingScoreDetails
101+
}
99102
if request.Filter != nil {
100103
params["filter"] = request.Filter
101104
}
@@ -141,11 +144,9 @@ func searchPostRequestParams(query string, request *SearchRequest) map[string]in
141144
if len(request.Sort) != 0 {
142145
params["sort"] = request.Sort
143146
}
144-
145147
if request.Vector != nil && len(request.Vector) > 0 {
146148
params["vector"] = request.Vector
147149
}
148-
149150
if request.Hybrid != nil {
150151
hybrid := make(map[string]interface{}, 2)
151152
hybrid["embedder"] = request.Hybrid.Embedder

index_search_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,6 +1599,32 @@ func TestIndex_SearchWithShowRankingScore(t *testing.T) {
15991599
require.NotNil(t, got.Hits[0].(map[string]interface{})["_rankingScore"])
16001600
}
16011601

1602+
func TestIndex_SearchWithShowRankingScoreDetails(t *testing.T) {
1603+
type args struct {
1604+
UID string
1605+
PrimaryKey string
1606+
client *Client
1607+
query string
1608+
request SearchRequest
1609+
}
1610+
testArg := args{
1611+
UID: "indexUID",
1612+
client: defaultClient,
1613+
query: "and",
1614+
request: SearchRequest{
1615+
ShowRankingScoreDetails: true,
1616+
},
1617+
}
1618+
SetUpIndexForFaceting()
1619+
c := testArg.client
1620+
i := c.Index(testArg.UID)
1621+
t.Cleanup(cleanup(c))
1622+
1623+
got, err := i.Search(testArg.query, &testArg.request)
1624+
require.NoError(t, err)
1625+
require.NotNil(t, got.Hits[0].(map[string]interface{})["_rankingScoreDetails"])
1626+
}
1627+
16021628
func TestIndex_SearchWithVectorStore(t *testing.T) {
16031629
type args struct {
16041630
UID string

types.go

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -337,29 +337,30 @@ type CreateIndexRequest struct {
337337
//
338338
// Documentation: https://www.meilisearch.com/docs/reference/api/search#search-parameters
339339
type SearchRequest struct {
340-
Offset int64
341-
Limit int64
342-
AttributesToRetrieve []string
343-
AttributesToSearchOn []string
344-
AttributesToCrop []string
345-
CropLength int64
346-
CropMarker string
347-
AttributesToHighlight []string
348-
HighlightPreTag string
349-
HighlightPostTag string
350-
MatchingStrategy string
351-
Filter interface{}
352-
ShowMatchesPosition bool
353-
ShowRankingScore bool
354-
Facets []string
355-
PlaceholderSearch bool
356-
Sort []string
357-
Vector []float32
358-
HitsPerPage int64
359-
Page int64
360-
IndexUID string
361-
Query string
362-
Hybrid *SearchRequestHybrid
340+
Offset int64
341+
Limit int64
342+
AttributesToRetrieve []string
343+
AttributesToSearchOn []string
344+
AttributesToCrop []string
345+
CropLength int64
346+
CropMarker string
347+
AttributesToHighlight []string
348+
HighlightPreTag string
349+
HighlightPostTag string
350+
MatchingStrategy string
351+
Filter interface{}
352+
ShowMatchesPosition bool
353+
ShowRankingScore bool
354+
ShowRankingScoreDetails bool
355+
Facets []string
356+
PlaceholderSearch bool
357+
Sort []string
358+
Vector []float32
359+
HitsPerPage int64
360+
Page int64
361+
IndexUID string
362+
Query string
363+
Hybrid *SearchRequestHybrid
363364
}
364365

365366
type SearchRequestHybrid struct {

types_easyjson.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)