mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-09 22:48:54 +01:00
Milli changes to match to allow for more flexible lifetimes
This commit is contained in:
parent
7fb3e378ff
commit
e83da00446
@ -46,7 +46,7 @@ impl<'m> MatcherBuilder<'m> {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn build<'t>(&'m self, text: &'t str) -> Matcher<'t, 'm> {
|
pub fn build<'t>(&self, text: &'t str) -> Matcher<'t, 'm, '_> {
|
||||||
let crop_marker = match &self.crop_marker {
|
let crop_marker = match &self.crop_marker {
|
||||||
Some(marker) => marker.as_str(),
|
Some(marker) => marker.as_str(),
|
||||||
None => DEFAULT_CROP_MARKER,
|
None => DEFAULT_CROP_MARKER,
|
||||||
@ -105,19 +105,19 @@ pub struct MatchBounds {
|
|||||||
pub length: usize,
|
pub length: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Structure used to analize a string, compute words that match,
|
/// Structure used to analyze a string, compute words that match,
|
||||||
/// and format the source string, returning a highlighted and cropped sub-string.
|
/// and format the source string, returning a highlighted and cropped sub-string.
|
||||||
pub struct Matcher<'t, 'm> {
|
pub struct Matcher<'t, 'tokenizer, 'b> {
|
||||||
text: &'t str,
|
text: &'t str,
|
||||||
matching_words: &'m MatchingWords,
|
matching_words: &'b MatchingWords,
|
||||||
tokenizer: &'m Tokenizer<'m>,
|
tokenizer: &'b Tokenizer<'tokenizer>,
|
||||||
crop_marker: &'m str,
|
crop_marker: &'b str,
|
||||||
highlight_prefix: &'m str,
|
highlight_prefix: &'b str,
|
||||||
highlight_suffix: &'m str,
|
highlight_suffix: &'b str,
|
||||||
matches: Option<(Vec<Token<'t>>, Vec<Match>)>,
|
matches: Option<(Vec<Token<'t>>, Vec<Match>)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'t> Matcher<'t, '_> {
|
impl<'t, 'tokenizer> Matcher<'t, 'tokenizer, '_> {
|
||||||
/// Iterates over tokens and save any of them that matches the query.
|
/// Iterates over tokens and save any of them that matches the query.
|
||||||
fn compute_matches(&mut self) -> &mut Self {
|
fn compute_matches(&mut self) -> &mut Self {
|
||||||
/// some words are counted as matches only if they are close together and in the good order,
|
/// some words are counted as matches only if they are close together and in the good order,
|
||||||
|
Loading…
Reference in New Issue
Block a user