diff --git a/meilidb-core/src/query_builder.rs b/meilidb-core/src/query_builder.rs index 7c3183ff4..d88e293b7 100644 --- a/meilidb-core/src/query_builder.rs +++ b/meilidb-core/src/query_builder.rs @@ -2,7 +2,7 @@ use std::hash::Hash; use std::ops::Range; use std::rc::Rc; use std::time::Instant; -use std::{cmp, mem}; +use std::{mem, cmp, cmp::Reverse}; use fst::{Streamer, IntoStreamer}; use hashbrown::HashMap; @@ -24,30 +24,38 @@ use crate::{TmpMatch, Highlight, DocumentId, Store, RawDocument, Document}; const NGRAMS: usize = 3; struct Automaton { + index: usize, + ngram: usize, query_len: usize, is_exact: bool, dfa: DFA, } impl Automaton { - fn exact(query: &str) -> Automaton { + fn exact(index: usize, ngram: usize, query: &str) -> Automaton { Automaton { + index, + ngram, query_len: query.len(), is_exact: true, dfa: build_dfa(query), } } - fn prefix_exact(query: &str) -> Automaton { + fn prefix_exact(index: usize, ngram: usize, query: &str) -> Automaton { Automaton { + index, + ngram, query_len: query.len(), is_exact: true, dfa: build_prefix_dfa(query), } } - fn non_exact(query: &str) -> Automaton { + fn non_exact(index: usize, ngram: usize, query: &str) -> Automaton { Automaton { + index, + ngram, query_len: query.len(), is_exact: false, dfa: build_dfa(query), @@ -82,9 +90,9 @@ fn generate_automatons(query: &str, store: &S) -> Result<(Vec(query: &str, store: &S) -> Result<(Vec(query: &str, store: &S) -> Result<(Vec