MeiliSearch/raptor/src/rank/number_of_words.rs

18 lines
433 B
Rust
Raw Normal View History

use std::cmp::Ordering;
use Match;
use rank::{match_query_index, Document};
use group_by::GroupBy;
2018-08-25 13:15:04 +02:00
#[inline]
fn number_of_query_words(matches: &[Match]) -> usize {
GroupBy::new(matches, match_query_index).count()
}
#[inline]
pub fn number_of_words(lhs: &Document, rhs: &Document) -> Ordering {
2018-08-25 13:15:04 +02:00
let lhs = number_of_query_words(&lhs.matches);
let rhs = number_of_query_words(&rhs.matches);
2018-08-25 13:15:04 +02:00
lhs.cmp(&rhs).reverse()
}