mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-22 18:17:39 +08: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
|
// 2. perform queries, merge and make hits index by index
|
||||||
let required_hit_count = federation.limit + federation.offset;
|
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
|
// 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
|
// Then in step (3), we'll update its value if there is any semantic search
|
||||||
let mut semantic_hit_count = None;
|
let mut semantic_hit_count = None;
|
||||||
@ -744,8 +741,6 @@ pub fn perform_federated_search(
|
|||||||
&index,
|
&index,
|
||||||
&rtxn,
|
&rtxn,
|
||||||
candidates,
|
candidates,
|
||||||
override_max_values_per_facet,
|
|
||||||
None,
|
|
||||||
super::Route::MultiSearch,
|
super::Route::MultiSearch,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@ -808,8 +803,6 @@ pub fn perform_federated_search(
|
|||||||
&index,
|
&index,
|
||||||
&rtxn,
|
&rtxn,
|
||||||
Default::default(),
|
Default::default(),
|
||||||
override_max_values_per_facet,
|
|
||||||
None,
|
|
||||||
super::Route::MultiSearch,
|
super::Route::MultiSearch,
|
||||||
) {
|
) {
|
||||||
error.message =
|
error.message =
|
||||||
|
@ -990,15 +990,7 @@ pub fn perform_search(
|
|||||||
|
|
||||||
let (facet_distribution, facet_stats) = facets
|
let (facet_distribution, facet_stats) = facets
|
||||||
.map(move |facets| {
|
.map(move |facets| {
|
||||||
compute_facet_distribution_stats(
|
compute_facet_distribution_stats(&facets, index, &rtxn, candidates, Route::Search)
|
||||||
&facets,
|
|
||||||
index,
|
|
||||||
&rtxn,
|
|
||||||
candidates,
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
Route::Search,
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
.transpose()?
|
.transpose()?
|
||||||
.map(|ComputedFacets { distribution, stats }| (distribution, stats))
|
.map(|ComputedFacets { distribution, stats }| (distribution, stats))
|
||||||
@ -1034,39 +1026,30 @@ fn compute_facet_distribution_stats<S: AsRef<str>>(
|
|||||||
index: &Index,
|
index: &Index,
|
||||||
rtxn: &RoTxn,
|
rtxn: &RoTxn,
|
||||||
candidates: roaring::RoaringBitmap,
|
candidates: roaring::RoaringBitmap,
|
||||||
override_max_values_per_facet: Option<usize>,
|
|
||||||
override_sort_facet_values_by: Option<OrderBy>,
|
|
||||||
route: Route,
|
route: Route,
|
||||||
) -> Result<ComputedFacets, ResponseError> {
|
) -> Result<ComputedFacets, ResponseError> {
|
||||||
let mut facet_distribution = index.facets_distribution(rtxn);
|
let mut facet_distribution = index.facets_distribution(rtxn);
|
||||||
|
|
||||||
let max_values_by_facet = match override_max_values_per_facet {
|
let max_values_by_facet = index
|
||||||
Some(max_values_by_facet) => max_values_by_facet,
|
.max_values_per_facet(rtxn)
|
||||||
None => index
|
.map_err(milli::Error::from)?
|
||||||
.max_values_per_facet(rtxn)
|
.map(|x| x as usize)
|
||||||
.map_err(milli::Error::from)?
|
.unwrap_or(DEFAULT_VALUES_PER_FACET);
|
||||||
.map(|x| x as usize)
|
|
||||||
.unwrap_or(DEFAULT_VALUES_PER_FACET),
|
|
||||||
};
|
|
||||||
|
|
||||||
facet_distribution.max_values_per_facet(max_values_by_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 = 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
|
// add specific facet if there is no placeholder
|
||||||
if facets.iter().all(|f| f.as_ref() != "*") {
|
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);
|
facet_distribution.facets(fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
let distribution = facet_distribution
|
let distribution = facet_distribution
|
||||||
.candidates(candidates)
|
.candidates(candidates)
|
||||||
.default_order_by(sort_facet_values_by("*"))
|
.default_order_by(sort_facet_values_by.get("*"))
|
||||||
.execute()
|
.execute()
|
||||||
.map_err(|error| match (error, route) {
|
.map_err(|error| match (error, route) {
|
||||||
(
|
(
|
||||||
|
Loading…
Reference in New Issue
Block a user