mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-09-20 11:46:25 +00:00
Add "position" part of the attribute ranking rule
This commit is contained in:
@ -95,7 +95,7 @@ fn create_index() -> TempIndex {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_attributes_simple() {
|
||||
fn test_attribute_fid_simple() {
|
||||
let index = create_index();
|
||||
|
||||
let txn = index.read_txn().unwrap();
|
52
milli/src/search/new/tests/attribute_position.rs
Normal file
52
milli/src/search/new/tests/attribute_position.rs
Normal file
@ -0,0 +1,52 @@
|
||||
use crate::{index::tests::TempIndex, 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!["text".to_owned()]);
|
||||
s.set_criteria(vec![Criterion::Attribute]);
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
index
|
||||
.add_documents(documents!([
|
||||
{
|
||||
"id": 0,
|
||||
"text": "do you know about the quick and talented brown fox",
|
||||
},
|
||||
{
|
||||
"id": 1,
|
||||
"text": "do you know about the quick brown fox",
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"text": "the quick and talented brown fox",
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"text": "fox brown quick the",
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"text": "the quick brown fox",
|
||||
},
|
||||
]))
|
||||
.unwrap();
|
||||
index
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_attribute_fid_simple() {
|
||||
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:?}"), @"[3, 4, 2, 1, 0]");
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
pub mod attribute;
|
||||
pub mod attribute_fid;
|
||||
pub mod attribute_position;
|
||||
pub mod distinct;
|
||||
#[cfg(feature = "default")]
|
||||
pub mod language;
|
||||
|
Reference in New Issue
Block a user