pub struct MultiFieldWeights {
pub name: f64,
pub version: f64,
pub ecosystem: f64,
pub licenses: f64,
pub supplier: f64,
pub group: f64,
pub ecosystem_mismatch_penalty: f64,
pub version_divergence_enabled: bool,
pub version_major_penalty: f64,
pub version_minor_penalty: f64,
}Expand description
Weights for multi-field scoring.
All weights should sum to 1.0 for normalized scoring. Fields with weight 0.0 are ignored in matching.
Penalty fields (negative values) are applied on top of the weighted score to penalize mismatches more strongly.
Fields§
§name: f64Weight for name similarity (primary field)
version: f64Weight for version match (exact match gives full score)
ecosystem: f64Weight for ecosystem match (exact match gives full score)
licenses: f64Weight for license overlap (Jaccard similarity of license sets)
supplier: f64Weight for supplier/publisher match
group: f64Weight for group/namespace match
ecosystem_mismatch_penalty: f64Penalty applied when ecosystems are different (negative value, e.g., -0.15)
version_divergence_enabled: boolEnable graduated version scoring based on semver distance
version_major_penalty: f64Penalty per major version difference (e.g., 0.10 = 10% per major)
version_minor_penalty: f64Penalty per minor version difference, capped (e.g., 0.02 = 2% per minor)
Implementations§
Source§impl MultiFieldWeights
impl MultiFieldWeights
Sourcepub const fn name_focused() -> Self
pub const fn name_focused() -> Self
Default weights emphasizing name matching.
Sourcepub const fn security_focused() -> Self
pub const fn security_focused() -> Self
Weights for security-focused matching (emphasizes ecosystem and version).
Sourcepub const fn legacy() -> Self
pub const fn legacy() -> Self
Legacy weights with no penalties (for backward compatibility).
Use this preset when you want the old binary scoring behavior without ecosystem mismatch penalties or version divergence scoring.
Sourcepub fn is_normalized(&self) -> bool
pub fn is_normalized(&self) -> bool
Check if weights are properly normalized (sum to ~1.0). Note: Penalty fields are not included in normalization check.
Trait Implementations§
Source§impl Clone for MultiFieldWeights
impl Clone for MultiFieldWeights
Source§fn clone(&self) -> MultiFieldWeights
fn clone(&self) -> MultiFieldWeights
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MultiFieldWeights
impl Debug for MultiFieldWeights
Source§impl Default for MultiFieldWeights
impl Default for MultiFieldWeights
Source§impl<'de> Deserialize<'de> for MultiFieldWeights
impl<'de> Deserialize<'de> for MultiFieldWeights
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for MultiFieldWeights
impl RefUnwindSafe for MultiFieldWeights
impl Send for MultiFieldWeights
impl Sync for MultiFieldWeights
impl Unpin for MultiFieldWeights
impl UnsafeUnpin for MultiFieldWeights
impl UnwindSafe for MultiFieldWeights
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more