mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-01-25 12:47:28 +01:00
add a failing test on the attribute ranking rule
This commit is contained in:
parent
b0afe0972e
commit
a0082c4df9
@ -2662,6 +2662,7 @@ pub(crate) mod tests {
|
|||||||
settings.set_filterable_fields(HashSet::from([S("age")]));
|
settings.set_filterable_fields(HashSet::from([S("age")]));
|
||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
// The order of the field id map shouldn't change
|
// The order of the field id map shouldn't change
|
||||||
db_snap!(index, fields_ids_map, @r###"
|
db_snap!(index, fields_ids_map, @r###"
|
||||||
0 name |
|
0 name |
|
||||||
@ -2676,4 +2677,54 @@ pub(crate) mod tests {
|
|||||||
3 1 |
|
3 1 |
|
||||||
"###);
|
"###);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn attribute_weights_after_swapping_searchable_attributes() {
|
||||||
|
// See https://github.com/meilisearch/meilisearch/issues/4484
|
||||||
|
|
||||||
|
let index = TempIndex::new();
|
||||||
|
|
||||||
|
index
|
||||||
|
.update_settings(|settings| {
|
||||||
|
settings.set_searchable_fields(vec![S("name"), S("beverage")]);
|
||||||
|
})
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
index
|
||||||
|
.add_documents(documents!([
|
||||||
|
{ "id": 0, "name": "kefir", "beverage": "water" },
|
||||||
|
{ "id": 1, "name": "tamo", "beverage": "kefir" }
|
||||||
|
]))
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let rtxn = index.read_txn().unwrap();
|
||||||
|
let mut search = index.search(&rtxn);
|
||||||
|
let results = search.query("kefir").execute().unwrap();
|
||||||
|
|
||||||
|
// We should find kefir the dog first
|
||||||
|
insta::assert_debug_snapshot!(results.documents_ids, @r###"
|
||||||
|
[
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
]
|
||||||
|
"###);
|
||||||
|
|
||||||
|
index
|
||||||
|
.update_settings(|settings| {
|
||||||
|
settings.set_searchable_fields(vec![S("beverage"), S("name")]);
|
||||||
|
})
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let rtxn = index.read_txn().unwrap();
|
||||||
|
let mut search = index.search(&rtxn);
|
||||||
|
let results = search.query("kefir").execute().unwrap();
|
||||||
|
|
||||||
|
// We should find tamo first
|
||||||
|
insta::assert_debug_snapshot!(results.documents_ids, @r###"
|
||||||
|
[
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
]
|
||||||
|
"###);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user