@@ -116,8 +116,8 @@ pub struct SearchResults<T> {
116116 /// facet stats of the numerical facets requested in the `facet` search parameter.
117117 pub facet_stats : Option < HashMap < String , FacetStats > > ,
118118 /// Indicates whether facet counts are exhaustive (exact) rather than estimated.
119- /// Present when the `exhaustiveFacetsCount ` search parameter is used.
120- pub exhaustive_facets_count : Option < bool > ,
119+ /// Present when the `exhaustiveFacetCount ` search parameter is used.
120+ pub exhaustive_facet_count : Option < bool > ,
121121 /// Processing time of the query.
122122 pub processing_time_ms : usize ,
123123 /// Query originating the response.
@@ -411,12 +411,12 @@ pub struct SearchQuery<'a, Http: HttpClient> {
411411 #[ serde( skip_serializing_if = "Option::is_none" ) ]
412412 pub retrieve_vectors : Option < bool > ,
413413
414- /// Return an exhaustive count of facets, up to the limit defined by `maxTotalHits`.
414+ /// Request exhaustive facet counts up to the limit defined by `maxTotalHits`.
415415 ///
416416 /// When set to `true`, Meilisearch computes exact facet counts instead of approximate ones.
417417 /// Default is `false`.
418418 #[ serde( skip_serializing_if = "Option::is_none" ) ]
419- pub exhaustive_facets_count : Option < bool > ,
419+ pub exhaustive_facet_count : Option < bool > ,
420420
421421 #[ serde( skip_serializing_if = "Option::is_none" ) ]
422422 pub ( crate ) federation_options : Option < QueryFederationOptions > ,
@@ -463,7 +463,7 @@ impl<'a, Http: HttpClient> SearchQuery<'a, Http> {
463463 hybrid : None ,
464464 vector : None ,
465465 retrieve_vectors : None ,
466- exhaustive_facets_count : None ,
466+ exhaustive_facet_count : None ,
467467 distinct : None ,
468468 ranking_score_threshold : None ,
469469 locales : None ,
@@ -732,12 +732,12 @@ impl<'a, Http: HttpClient> SearchQuery<'a, Http> {
732732 self . clone ( )
733733 }
734734
735- /// Request exhaustive facet counts in the response.
736- pub fn with_exhaustive_facets_count < ' b > (
735+ /// Request exhaustive facet count in the response.
736+ pub fn with_exhaustive_facet_count < ' b > (
737737 & ' b mut self ,
738738 exhaustive : bool ,
739739 ) -> & ' b mut SearchQuery < ' a , Http > {
740- self . exhaustive_facets_count = Some ( exhaustive) ;
740+ self . exhaustive_facet_count = Some ( exhaustive) ;
741741 self
742742 }
743743
@@ -1116,6 +1116,7 @@ pub(crate) mod tests {
11161116 search:: * ,
11171117 settings:: EmbedderSource ,
11181118 } ;
1119+ use crate :: errors:: { ErrorCode , MeilisearchError } ;
11191120 use big_s:: S ;
11201121 use meilisearch_test_macro:: meilisearch_test;
11211122 use serde:: { Deserialize , Serialize } ;
@@ -1988,6 +1989,64 @@ pub(crate) mod tests {
19881989 Ok ( ( ) )
19891990 }
19901991
1992+ #[ meilisearch_test]
1993+ async fn test_search_with_exhaustive_facet_count (
1994+ client : Client ,
1995+ index : Index ,
1996+ ) -> Result < ( ) , Error > {
1997+ setup_test_index ( & client, & index) . await ?;
1998+
1999+ // Request exhaustive facet counts for a specific facet and ensure the server
2000+ // returns the exhaustive flag in the response.
2001+ let mut query = SearchQuery :: new ( & index) ;
2002+ query
2003+ . with_facets ( Selectors :: Some ( & [ "kind" ] ) )
2004+ . with_exhaustive_facet_count ( true ) ;
2005+
2006+ let res = index. execute_query :: < Document > ( & query) . await ;
2007+ match res {
2008+ Ok ( results) => {
2009+ assert ! ( results. exhaustive_facet_count. is_some( ) ) ;
2010+ Ok ( ( ) )
2011+ }
2012+ Err ( error)
2013+ if matches ! (
2014+ error,
2015+ Error :: Meilisearch ( MeilisearchError {
2016+ error_code: ErrorCode :: BadRequest ,
2017+ ..
2018+ } )
2019+ ) =>
2020+ {
2021+ // Server doesn't support this field on /search yet; treat as a skip.
2022+ Ok ( ( ) )
2023+ }
2024+ Err ( e) => Err ( e) ,
2025+ }
2026+ }
2027+
2028+ #[ test]
2029+ fn test_search_query_serialization_exhaustive_facet_count ( ) {
2030+ // Build a query and ensure it serializes using the expected camelCase field name
2031+ let client = Client :: new (
2032+ option_env ! ( "MEILISEARCH_URL" ) . unwrap_or ( "http://localhost:7700" ) ,
2033+ Some ( option_env ! ( "MEILISEARCH_API_KEY" ) . unwrap_or ( "masterKey" ) ) ,
2034+ )
2035+ . unwrap ( ) ;
2036+ let index = client. index ( "dummy" ) ;
2037+
2038+ let mut query = SearchQuery :: new ( & index) ;
2039+ query
2040+ . with_facets ( Selectors :: Some ( & [ "kind" ] ) )
2041+ . with_exhaustive_facet_count ( true ) ;
2042+
2043+ let v = serde_json:: to_value ( & query) . unwrap ( ) ;
2044+ assert_eq ! (
2045+ v. get( "exhaustiveFacetCount" ) . and_then( |b| b. as_bool( ) ) ,
2046+ Some ( true )
2047+ ) ;
2048+ }
2049+
19912050 #[ meilisearch_test]
19922051 async fn test_facet_search_with_facet_query ( client : Client , index : Index ) -> Result < ( ) , Error > {
19932052 setup_test_index ( & client, & index) . await ?;
0 commit comments