mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-03-06 22:02:34 +08:00
Fix inconsistency in attribute ranking rule computation
**Changes:** The building of the Attributes ranking rule graph was comparing fieldids with weights which doesn't make sense and may be bug prone, we are now comparing fieldids with fieldids. **Impact:** - search: Attribute ranking rule
This commit is contained in:
parent
4f7ece2411
commit
286d310287
@ -48,6 +48,11 @@ impl FieldidsWeightsMap {
|
|||||||
self.map.values().copied().max()
|
self.map.values().copied().max()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the field id with the highest weight.
|
||||||
|
pub fn max_weight_fid(&self) -> Option<(FieldId, Weight)> {
|
||||||
|
self.map.iter().max_by_key(|(_, weight)| *weight).map(|(fid, weight)| (*fid, *weight))
|
||||||
|
}
|
||||||
|
|
||||||
/// Return an iterator visiting all field ids in arbitrary order.
|
/// Return an iterator visiting all field ids in arbitrary order.
|
||||||
pub fn ids(&self) -> impl Iterator<Item = FieldId> + '_ {
|
pub fn ids(&self) -> impl Iterator<Item = FieldId> + '_ {
|
||||||
self.map.keys().copied()
|
self.map.keys().copied()
|
||||||
|
@ -88,10 +88,10 @@ impl RankingRuleGraphTrait for FidGraph {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// always lookup the max_fid if we don't already and add an artificial condition for max scoring
|
// always lookup the max_fid if we don't already and add an artificial condition for max scoring
|
||||||
let max_weight: Option<u16> = weights_map.max_weight();
|
let max_weight_fid = weights_map.max_weight_fid();
|
||||||
|
|
||||||
if let Some(max_weight) = max_weight {
|
if let Some((max_fid, max_weight)) = max_weight_fid {
|
||||||
if !all_fields.contains(&max_weight) {
|
if !all_fields.contains(&max_fid) {
|
||||||
edges.push((
|
edges.push((
|
||||||
max_weight as u32 * term.term_ids.len() as u32, // TODO improve the fid score i.e. fid^10.
|
max_weight as u32 * term.term_ids.len() as u32, // TODO improve the fid score i.e. fid^10.
|
||||||
conditions_interner.insert(FidCondition {
|
conditions_interner.insert(FidCondition {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user