@@ -51,6 +51,8 @@ pub struct SearchResult<T> {
51
51
/// The relevancy score of the match.
52
52
#[ serde( rename = "_rankingScore" ) ]
53
53
pub ranking_score : Option < f64 > ,
54
+ #[ serde( rename = "_rankingScoreDetails" ) ]
55
+ pub ranking_score_details : Option < Map < String , Value > > ,
54
56
}
55
57
56
58
#[ derive( Deserialize , Debug , Clone ) ]
@@ -322,6 +324,12 @@ pub struct SearchQuery<'a, Http: HttpClient> {
322
324
#[ serde( skip_serializing_if = "Option::is_none" ) ]
323
325
pub show_ranking_score : Option < bool > ,
324
326
327
+ ///Adds a detailed global ranking score field to each document.
328
+ ///
329
+ /// **Default: `false`**
330
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
331
+ pub show_ranking_score_details : Option < bool > ,
332
+
325
333
/// Defines the strategy on how to handle queries containing multiple words.
326
334
#[ serde( skip_serializing_if = "Option::is_none" ) ]
327
335
pub matching_strategy : Option < MatchingStrategies > ,
@@ -354,6 +362,7 @@ impl<'a, Http: HttpClient> SearchQuery<'a, Http> {
354
362
highlight_post_tag : None ,
355
363
show_matches_position : None ,
356
364
show_ranking_score : None ,
365
+ show_ranking_score_details : None ,
357
366
matching_strategy : None ,
358
367
index_uid : None ,
359
368
}
@@ -528,6 +537,15 @@ impl<'a, Http: HttpClient> SearchQuery<'a, Http> {
528
537
self . show_ranking_score = Some ( show_ranking_score) ;
529
538
self
530
539
}
540
+
541
+ pub fn with_show_ranking_score_details < ' b > (
542
+ & ' b mut self ,
543
+ show_ranking_score_details : bool ,
544
+ ) -> & ' b mut SearchQuery < ' a , Http > {
545
+ self . show_ranking_score_details = Some ( show_ranking_score_details) ;
546
+ self
547
+ }
548
+
531
549
pub fn with_matching_strategy < ' b > (
532
550
& ' b mut self ,
533
551
matching_strategy : MatchingStrategies ,
@@ -1090,6 +1108,18 @@ mod tests {
1090
1108
Ok ( ( ) )
1091
1109
}
1092
1110
1111
+ #[ meilisearch_test]
1112
+ async fn test_query_show_ranking_score_details ( client : Client , index : Index ) -> Result < ( ) , Error > {
1113
+ setup_test_index ( & client, & index) . await ?;
1114
+
1115
+ let mut query = SearchQuery :: new ( & index) ;
1116
+ query. with_query ( "dolor text" ) ;
1117
+ query. with_show_ranking_score_details ( true ) ;
1118
+ let results: SearchResults < Document > = index. execute_query ( & query) . await . unwrap ( ) ;
1119
+ assert ! ( results. hits[ 0 ] . ranking_score_details. is_some( ) ) ;
1120
+ Ok ( ( ) )
1121
+ }
1122
+
1093
1123
#[ meilisearch_test]
1094
1124
async fn test_phrase_search ( client : Client , index : Index ) -> Result < ( ) , Error > {
1095
1125
setup_test_index ( & client, & index) . await ?;
0 commit comments