Skip to content

Commit 1036295

Browse files
committed
Add exhaustive facet search
1 parent e90a3c2 commit 1036295

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/search.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ pub struct SearchResults<T> {
115115
pub facet_distribution: Option<HashMap<String, HashMap<String, usize>>>,
116116
/// facet stats of the numerical facets requested in the `facet` search parameter.
117117
pub facet_stats: Option<HashMap<String, FacetStats>>,
118+
/// 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>,
118121
/// Processing time of the query.
119122
pub processing_time_ms: usize,
120123
/// Query originating the response.
@@ -408,6 +411,13 @@ pub struct SearchQuery<'a, Http: HttpClient> {
408411
#[serde(skip_serializing_if = "Option::is_none")]
409412
pub retrieve_vectors: Option<bool>,
410413

414+
/// Return an exhaustive count of facets, up to the limit defined by `maxTotalHits`.
415+
///
416+
/// When set to `true`, Meilisearch computes exact facet counts instead of approximate ones.
417+
/// Default is `false`.
418+
#[serde(skip_serializing_if = "Option::is_none")]
419+
pub exhaustive_facets_count: Option<bool>,
420+
411421
#[serde(skip_serializing_if = "Option::is_none")]
412422
pub(crate) federation_options: Option<QueryFederationOptions>,
413423
}
@@ -453,6 +463,7 @@ impl<'a, Http: HttpClient> SearchQuery<'a, Http> {
453463
hybrid: None,
454464
vector: None,
455465
retrieve_vectors: None,
466+
exhaustive_facets_count: None,
456467
distinct: None,
457468
ranking_score_threshold: None,
458469
locales: None,
@@ -721,6 +732,15 @@ impl<'a, Http: HttpClient> SearchQuery<'a, Http> {
721732
self.clone()
722733
}
723734

735+
/// Request exhaustive facet counts in the response.
736+
pub fn with_exhaustive_facets_count<'b>(
737+
&'b mut self,
738+
exhaustive: bool,
739+
) -> &'b mut SearchQuery<'a, Http> {
740+
self.exhaustive_facets_count = Some(exhaustive);
741+
self
742+
}
743+
724744
/// Execute the query and fetch the results.
725745
pub async fn execute<T: 'static + DeserializeOwned + Send + Sync>(
726746
&'a self,

0 commit comments

Comments
 (0)