Repository: meilisearch/meilisearch
File: crates/milli/src/search/new/mod.rs (Rust)

Code before:
            if exact_attributes_ids.contains(&fid) {
                restricted_fids.exact.push((fid, weight));
            } else {
                restricted_fids.tolerant.push((fid, weight));
            };
        }

        if universal_wildcard {
            self.restricted_fids = None;
        } else {
            self.restricted_fids = Some(restricted_fids);
        }

        Ok(())
    }

    fn matches_wildcard_pattern(wildcard_pattern: &str, name: &str) -> bool {
        let wildcard_subfields: Vec<&str> = wildcard_pattern.split(".").collect();
        let name_subfields: Vec<&str> = name.split(".").collect();

        // Deep wildcard matches all attributes after ('**')
        if !wildcard_subfields.is_empty() && wildcard_subfields.last() == Some(&"**") {
            let prefix_len = wildcard_subfields.len() - 1;
            if prefix_len > name_subfields.len() {
                return false;
            }

            return wildcard_subfields[..prefix_len]
                .iter()
                .zip(name_subfields.iter())
                .all(|(wc, sf)| *wc == "*" || *wc == *sf);
        }

        // Using single wildcard ('*') should match length (e.g. 'a.*.c' matches 'a.b.c')
        // where '*' can match any single segment
        if wildcard_subfields.len() != name_subfields.len() {
            return false;
        }

        wildcard_subfields.iter()
            .zip(name_subfields.iter())
            .all(|(wc, sf)| *wc == "*" || *wc == *sf)
    }
}

#[derive(Debug, Default)]
pub struct VectorStoreStats {
    /// The total time spent on vector search.
    pub total_time: Duration,
    /// The number of searches performed.
    pub total_queries: usize,

Review comment (refactor):
the `**` has not been requested,
even if it can be usefull, I suggest simplifying this case with `*` 

Code after:
                restricted_fids.exact.push((fid, weight));
            } else {
                restricted_fids.tolerant.push((fid, weight));
            };
        }

        if universal_wildcard {
            self.restricted_fids = None;
        } else {
            self.restricted_fids = Some(restricted_fids);
        }

        Ok(())
    }
}

#[derive(Debug, Default)]
pub struct VectorStoreStats {
    /// The total time spent on vector search.
    pub total_time: Duration,
    /// The number of searches performed.
    pub total_queries: usize,
    /// The number of nearest neighbors found.
    pub total_results: usize,
}

impl AddAssign for VectorStoreStats {
    fn add_assign(&mut self, other: Self) {
        let Self { total_time, total_queries, total_results } = self;
        *total_time += other.total_time;
        *total_queries += other.total_queries;
        *total_results += other.total_results;
    }
}

#[derive(Clone, Copy, PartialEq, PartialOrd, Ord, Eq)]
pub enum Word {
    Original(Interned<String>),
    Derived(Interned<String>),
}

impl Word {
    pub fn interned(&self) -> Interned<String> {
        match self {
            Word::Original(word) => *word,
            Word::Derived(word) => *word,
        }
    }
}

#[derive(Debug, Clone, Default)]