pub struct ValueMatcher { /* private fields */ }Expand description
A search text prepared for matching many values.
Implementations§
Source§impl ValueMatcher
impl ValueMatcher
Sourcepub const DEFAULT_MIN_SIMILARITY: f64 = 0.6
pub const DEFAULT_MIN_SIMILARITY: f64 = 0.6
The least similarity a similar match needs when none is given.
Sourcepub fn new(
text: &str,
matching: TextMatch,
case_sensitive: bool,
min_similarity: Option<f64>,
) -> Self
pub fn new( text: &str, matching: TextMatch, case_sensitive: bool, min_similarity: Option<f64>, ) -> Self
Prepares text for matching (case-insensitive unless
case_sensitive); min_similarity applies to similar only.
Sourcepub fn matches_text(&self, text: &str) -> bool
pub fn matches_text(&self, text: &str) -> bool
Whether a text value matches, as Self::matches does for the
string text, without building the JSON value.
Sourcepub fn may_match(&self, ty: LogicalType) -> bool
pub fn may_match(&self, ty: LogicalType) -> bool
Whether a value of ty can match: false only when no rendering of
that type can contain the text, so a caller may skip the type’s
values without changing the result. Numbers render with digits,
., -, + and e; booleans as true/false; datetimes as a
year-first date with an optional T…Z time. similar and a text
that reads as a date can match any type.
Sourcepub fn similarity(&self, value: &Json) -> f64
pub fn similarity(&self, value: &Json) -> f64
How close value is to the text, from 0 to 1 (see similarity);
arrays score their closest element.