mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-22 12:54:26 +01:00
Add a simple test to check that attributes are ranking correctly
This commit is contained in:
parent
30f7bd03f6
commit
d9cebff61c
@ -25,7 +25,7 @@ impl RankingRuleGraphTrait for AttributeGraph {
|
||||
universe: &RoaringBitmap,
|
||||
) -> Result<ComputedCondition> {
|
||||
let AttributeCondition { term, .. } = condition;
|
||||
// maybe compute_query_term_subset_docids should accept a universe as argument
|
||||
// maybe compute_query_term_subset_docids_within_field_id should accept a universe as argument
|
||||
let mut docids = compute_query_term_subset_docids_within_field_id(
|
||||
ctx,
|
||||
&term.term_subset,
|
||||
|
58
milli/src/search/new/tests/attribute.rs
Normal file
58
milli/src/search/new/tests/attribute.rs
Normal file
@ -0,0 +1,58 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::{
|
||||
index::tests::TempIndex, search::new::tests::collect_field_values, Criterion, Search,
|
||||
SearchResult, TermsMatchingStrategy,
|
||||
};
|
||||
|
||||
fn create_index() -> TempIndex {
|
||||
let index = TempIndex::new();
|
||||
|
||||
index
|
||||
.update_settings(|s| {
|
||||
s.set_primary_key("id".to_owned());
|
||||
s.set_searchable_fields(vec![
|
||||
"title".to_owned(),
|
||||
"description".to_owned(),
|
||||
"plot".to_owned(),
|
||||
]);
|
||||
s.set_criteria(vec![Criterion::Attribute]);
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
index
|
||||
.add_documents(documents!([
|
||||
{
|
||||
"id": 0,
|
||||
"title": "the quick brown fox jumps over the lazy dog",
|
||||
"description": "Pack my box with five dozen liquor jugs",
|
||||
"plot": "How vexingly quick daft zebras jump",
|
||||
},
|
||||
{
|
||||
"id": 1,
|
||||
"title": "Pack my box with five dozen liquor jugs",
|
||||
"description": "the quick brown foxes jump over the lazy dog",
|
||||
"plot": "How vexingly quick daft zebras jump",
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"title": "How vexingly quick daft zebras jump",
|
||||
"description": "Pack my box with five dozen liquor jugs",
|
||||
"plot": "the quick brown fox jumps over the lazy dog",
|
||||
}
|
||||
]))
|
||||
.unwrap();
|
||||
index
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_attributes_are_ranked_correctly() {
|
||||
let index = create_index();
|
||||
let txn = index.read_txn().unwrap();
|
||||
|
||||
let mut s = Search::new(&txn, &index);
|
||||
s.terms_matching_strategy(TermsMatchingStrategy::All);
|
||||
s.query("the quick brown fox");
|
||||
let SearchResult { documents_ids, .. } = s.execute().unwrap();
|
||||
insta::assert_snapshot!(format!("{documents_ids:?}"), @"[0, 1, 2]");
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
pub mod attribute;
|
||||
pub mod distinct;
|
||||
#[cfg(feature = "default")]
|
||||
pub mod language;
|
||||
|
Loading…
Reference in New Issue
Block a user