MeiliSearch/src/rank/mod.rs

33 lines
770 B
Rust
Raw Normal View History

2018-10-10 16:57:21 +02:00
pub mod criterion;
mod ranked_stream;
use crate::{Match, DocumentId};
2018-05-27 15:23:43 +02:00
pub use self::ranked_stream::{Config, RankedStream};
2018-05-27 15:23:43 +02:00
#[inline]
fn match_query_index(a: &Match, b: &Match) -> bool {
a.query_index == b.query_index
}
#[derive(Debug, Clone)]
2018-05-27 15:23:43 +02:00
pub struct Document {
2018-10-10 16:57:21 +02:00
pub id: DocumentId,
pub matches: Vec<Match>,
2018-05-27 15:23:43 +02:00
}
impl Document {
pub fn new(doc: DocumentId, match_: Match) -> Self {
2018-10-11 14:04:41 +02:00
unsafe { Self::from_sorted_matches(doc, vec![match_]) }
2018-05-27 15:23:43 +02:00
}
pub fn from_matches(doc: DocumentId, mut matches: Vec<Match>) -> Self {
matches.sort_unstable();
unsafe { Self::from_sorted_matches(doc, matches) }
}
2018-10-11 14:04:41 +02:00
pub unsafe fn from_sorted_matches(id: DocumentId, matches: Vec<Match>) -> Self {
2018-10-10 16:57:21 +02:00
Self { id, matches }
2018-05-27 15:23:43 +02:00
}
}