mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-25 22:34:28 +01:00
Don't override max value in indexes
This commit is contained in:
parent
52a52f97cf
commit
174d69ff72
@ -496,9 +496,6 @@ pub fn perform_federated_search(
|
||||
// 2. perform queries, merge and make hits index by index
|
||||
let required_hit_count = federation.limit + federation.offset;
|
||||
|
||||
let override_max_values_per_facet =
|
||||
federation.merge_facets.and_then(|merge_facets| merge_facets.max_values_per_facet);
|
||||
|
||||
// In step (2), semantic_hit_count will be set to Some(0) if any search kind uses semantic
|
||||
// Then in step (3), we'll update its value if there is any semantic search
|
||||
let mut semantic_hit_count = None;
|
||||
@ -744,8 +741,6 @@ pub fn perform_federated_search(
|
||||
&index,
|
||||
&rtxn,
|
||||
candidates,
|
||||
override_max_values_per_facet,
|
||||
None,
|
||||
super::Route::MultiSearch,
|
||||
)
|
||||
})
|
||||
@ -808,8 +803,6 @@ pub fn perform_federated_search(
|
||||
&index,
|
||||
&rtxn,
|
||||
Default::default(),
|
||||
override_max_values_per_facet,
|
||||
None,
|
||||
super::Route::MultiSearch,
|
||||
) {
|
||||
error.message =
|
||||
|
@ -990,15 +990,7 @@ pub fn perform_search(
|
||||
|
||||
let (facet_distribution, facet_stats) = facets
|
||||
.map(move |facets| {
|
||||
compute_facet_distribution_stats(
|
||||
&facets,
|
||||
index,
|
||||
&rtxn,
|
||||
candidates,
|
||||
None,
|
||||
None,
|
||||
Route::Search,
|
||||
)
|
||||
compute_facet_distribution_stats(&facets, index, &rtxn, candidates, Route::Search)
|
||||
})
|
||||
.transpose()?
|
||||
.map(|ComputedFacets { distribution, stats }| (distribution, stats))
|
||||
@ -1034,39 +1026,30 @@ fn compute_facet_distribution_stats<S: AsRef<str>>(
|
||||
index: &Index,
|
||||
rtxn: &RoTxn,
|
||||
candidates: roaring::RoaringBitmap,
|
||||
override_max_values_per_facet: Option<usize>,
|
||||
override_sort_facet_values_by: Option<OrderBy>,
|
||||
route: Route,
|
||||
) -> Result<ComputedFacets, ResponseError> {
|
||||
let mut facet_distribution = index.facets_distribution(rtxn);
|
||||
|
||||
let max_values_by_facet = match override_max_values_per_facet {
|
||||
Some(max_values_by_facet) => max_values_by_facet,
|
||||
None => index
|
||||
let max_values_by_facet = index
|
||||
.max_values_per_facet(rtxn)
|
||||
.map_err(milli::Error::from)?
|
||||
.map(|x| x as usize)
|
||||
.unwrap_or(DEFAULT_VALUES_PER_FACET),
|
||||
};
|
||||
.unwrap_or(DEFAULT_VALUES_PER_FACET);
|
||||
|
||||
facet_distribution.max_values_per_facet(max_values_by_facet);
|
||||
|
||||
let sort_facet_values_by = index.sort_facet_values_by(rtxn).map_err(milli::Error::from)?;
|
||||
|
||||
let sort_facet_values_by = |n: &str| match override_sort_facet_values_by {
|
||||
Some(order_by) => order_by,
|
||||
None => sort_facet_values_by.get(n),
|
||||
};
|
||||
|
||||
// add specific facet if there is no placeholder
|
||||
if facets.iter().all(|f| f.as_ref() != "*") {
|
||||
let fields: Vec<_> = facets.iter().map(|n| (n, sort_facet_values_by(n.as_ref()))).collect();
|
||||
let fields: Vec<_> =
|
||||
facets.iter().map(|n| (n, sort_facet_values_by.get(n.as_ref()))).collect();
|
||||
facet_distribution.facets(fields);
|
||||
}
|
||||
|
||||
let distribution = facet_distribution
|
||||
.candidates(candidates)
|
||||
.default_order_by(sort_facet_values_by("*"))
|
||||
.default_order_by(sort_facet_values_by.get("*"))
|
||||
.execute()
|
||||
.map_err(|error| match (error, route) {
|
||||
(
|
||||
|
Loading…
Reference in New Issue
Block a user