mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-26 03:55:07 +08:00
Force exhaustive search when faceting is requested
This commit is contained in:
parent
39b62b7158
commit
67b8678afb
@ -144,6 +144,11 @@ pub fn perform_search(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let is_finite_pagination = query.is_finite_pagination();
|
let is_finite_pagination = query.is_finite_pagination();
|
||||||
|
let has_facet_distribution =
|
||||||
|
if let Some(facets) = query.facets.as_deref() { !facets.is_empty() } else { false };
|
||||||
|
|
||||||
|
search.exhaustive_number_hits(is_finite_pagination || has_facet_distribution);
|
||||||
|
|
||||||
search.terms_matching_strategy(query.matching_strategy.into());
|
search.terms_matching_strategy(query.matching_strategy.into());
|
||||||
|
|
||||||
let max_total_hits = index
|
let max_total_hits = index
|
||||||
@ -151,8 +156,6 @@ pub fn perform_search(
|
|||||||
.map_err(milli::Error::from)?
|
.map_err(milli::Error::from)?
|
||||||
.unwrap_or(DEFAULT_PAGINATION_MAX_TOTAL_HITS);
|
.unwrap_or(DEFAULT_PAGINATION_MAX_TOTAL_HITS);
|
||||||
|
|
||||||
search.exhaustive_number_hits(is_finite_pagination);
|
|
||||||
|
|
||||||
// compute the offset on the limit depending on the pagination mode.
|
// compute the offset on the limit depending on the pagination mode.
|
||||||
let (offset, limit) = if is_finite_pagination {
|
let (offset, limit) = if is_finite_pagination {
|
||||||
let limit = query.hits_per_page.unwrap_or_else(DEFAULT_SEARCH_LIMIT);
|
let limit = query.hits_per_page.unwrap_or_else(DEFAULT_SEARCH_LIMIT);
|
||||||
|
@ -112,7 +112,7 @@ impl<'a> Search<'a> {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Force the search to exhastivelly compute the number of candidates,
|
/// Force the search to exhaustively compute the number of candidates,
|
||||||
/// this will increase the search time but allows finite pagination.
|
/// this will increase the search time but allows finite pagination.
|
||||||
pub fn exhaustive_number_hits(&mut self, exhaustive_number_hits: bool) -> &mut Search<'a> {
|
pub fn exhaustive_number_hits(&mut self, exhaustive_number_hits: bool) -> &mut Search<'a> {
|
||||||
self.exhaustive_number_hits = exhaustive_number_hits;
|
self.exhaustive_number_hits = exhaustive_number_hits;
|
||||||
|
Loading…
Reference in New Issue
Block a user