mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 20:37:15 +02:00
Remove limit of 1000 position per attribute
Instead of using an arbitrary limit we encode the absolute position in a u32 using one strong u16 for the field id and a weak u16 for the relative position in the attribute.
This commit is contained in:
parent
8f6b6c9042
commit
360c5ff3df
6 changed files with 91 additions and 24 deletions
|
@ -884,6 +884,44 @@ mod tests {
|
|||
wtxn.commit().unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn index_more_than_1000_positions_in_a_field() {
|
||||
let path = tempfile::tempdir().unwrap();
|
||||
let mut options = EnvOpenOptions::new();
|
||||
options.map_size(50 * 1024 * 1024); // 10 MB
|
||||
let index = Index::new(options, &path).unwrap();
|
||||
|
||||
let mut wtxn = index.write_txn().unwrap();
|
||||
|
||||
let mut big_object = HashMap::new();
|
||||
big_object.insert(S("id"), "wow");
|
||||
let content: String =
|
||||
(0..=u16::MAX).into_iter().map(|p| p.to_string()).reduce(|a, b| a + " " + &b).unwrap();
|
||||
big_object.insert("content".to_string(), &content);
|
||||
|
||||
let mut cursor = Cursor::new(Vec::new());
|
||||
|
||||
let mut builder = DocumentBatchBuilder::new(&mut cursor).unwrap();
|
||||
builder.add_documents(big_object).unwrap();
|
||||
builder.finish().unwrap();
|
||||
cursor.set_position(0);
|
||||
let content = DocumentBatchReader::from_reader(cursor).unwrap();
|
||||
|
||||
let builder = IndexDocuments::new(&mut wtxn, &index, 0);
|
||||
builder.execute(content, |_, _| ()).unwrap();
|
||||
|
||||
wtxn.commit().unwrap();
|
||||
|
||||
let mut rtxn = index.read_txn().unwrap();
|
||||
|
||||
assert!(index.word_docids.get(&mut rtxn, "0").unwrap().is_some());
|
||||
assert!(index.word_docids.get(&mut rtxn, "64").unwrap().is_some());
|
||||
assert!(index.word_docids.get(&mut rtxn, "256").unwrap().is_some());
|
||||
assert!(index.word_docids.get(&mut rtxn, "1024").unwrap().is_some());
|
||||
assert!(index.word_docids.get(&mut rtxn, "32768").unwrap().is_some());
|
||||
assert!(index.word_docids.get(&mut rtxn, "65535").unwrap().is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn index_documents_with_zeroes() {
|
||||
let path = tempfile::tempdir().unwrap();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue