mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-30 00:55:00 +08:00
remove more warnings and fix some tests
This commit is contained in:
parent
fa6c7f65ca
commit
290e773d23
@ -1861,8 +1861,7 @@ pub(crate) mod tests {
|
||||
use big_s::S;
|
||||
use maplit::hashset;
|
||||
|
||||
let mut index = TempIndex::new();
|
||||
let index = index;
|
||||
let index = TempIndex::new();
|
||||
|
||||
index
|
||||
.update_settings(|settings| {
|
||||
@ -1973,7 +1972,7 @@ pub(crate) mod tests {
|
||||
use big_s::S;
|
||||
use maplit::hashset;
|
||||
|
||||
let mut index = TempIndex::new();
|
||||
let index = TempIndex::new();
|
||||
|
||||
index
|
||||
.update_settings(|settings| {
|
||||
@ -2561,10 +2560,7 @@ pub(crate) mod tests {
|
||||
4 2
|
||||
"###);
|
||||
|
||||
let mut wtxn = index.write_txn().unwrap();
|
||||
let mut delete = DeleteDocuments::new(&mut wtxn, &index).unwrap();
|
||||
delete.execute().unwrap();
|
||||
wtxn.commit().unwrap();
|
||||
index.delete_documents(Default::default());
|
||||
|
||||
db_snap!(index, documents_ids, @"[0, 2, 3, ]");
|
||||
db_snap!(index, external_documents_ids, @r###"
|
||||
|
@ -4,9 +4,8 @@ use std::path::Path;
|
||||
|
||||
use roaring::RoaringBitmap;
|
||||
|
||||
use crate::facet::FacetType;
|
||||
use crate::heed_codec::facet::{FacetGroupKey, FacetGroupValue};
|
||||
use crate::{make_db_snap_from_iter, obkv_to_json, ExternalDocumentsIds, Index};
|
||||
use crate::{make_db_snap_from_iter, obkv_to_json, Index};
|
||||
|
||||
#[track_caller]
|
||||
pub fn default_db_snapshot_settings_for_test(name: Option<&str>) -> (insta::Settings, String) {
|
||||
|
@ -566,7 +566,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn replace_all_identical_soft_deletion_then_hard_deletion() {
|
||||
let mut index = TempIndex::new_with_map_size(4096 * 1000 * 100);
|
||||
let index = TempIndex::new_with_map_size(4096 * 1000 * 100);
|
||||
|
||||
index
|
||||
.update_settings(|settings| {
|
||||
|
@ -696,7 +696,6 @@ mod tests {
|
||||
use crate::documents::documents_batch_reader_from_objects;
|
||||
use crate::index::tests::TempIndex;
|
||||
use crate::search::TermsMatchingStrategy;
|
||||
use crate::update::DeleteDocuments;
|
||||
use crate::{db_snap, BEU16};
|
||||
|
||||
#[test]
|
||||
@ -1101,17 +1100,15 @@ mod tests {
|
||||
{ "objectId": 30, "title": "Hamlet", "_geo": { "lat": 12, "lng": 89 } }
|
||||
]))
|
||||
.unwrap();
|
||||
let mut wtxn = index.write_txn().unwrap();
|
||||
assert_eq!(index.primary_key(&wtxn).unwrap(), Some("objectId"));
|
||||
|
||||
// Delete not all of the documents but some of them.
|
||||
let mut builder = DeleteDocuments::new(&mut wtxn, &index).unwrap();
|
||||
builder.delete_external_id("30");
|
||||
builder.execute().unwrap();
|
||||
index.delete_document("30");
|
||||
|
||||
let external_documents_ids = index.external_documents_ids(&wtxn).unwrap();
|
||||
let txn = index.read_txn().unwrap();
|
||||
assert_eq!(index.primary_key(&txn).unwrap(), Some("objectId"));
|
||||
|
||||
let external_documents_ids = index.external_documents_ids(&txn).unwrap();
|
||||
assert!(external_documents_ids.get("30").is_none());
|
||||
wtxn.commit().unwrap();
|
||||
|
||||
index
|
||||
.add_documents(documents!([
|
||||
@ -2493,16 +2490,8 @@ mod tests {
|
||||
db_snap!(index, word_fid_docids, 2, @"a48d3f88db33f94bc23110a673ea49e4");
|
||||
db_snap!(index, word_position_docids, 2, @"3c9e66c6768ae2cf42b46b2c46e46a83");
|
||||
|
||||
let mut wtxn = index.write_txn().unwrap();
|
||||
|
||||
// Delete not all of the documents but some of them.
|
||||
let mut builder = DeleteDocuments::new(&mut wtxn, &index).unwrap();
|
||||
builder.delete_external_id("0");
|
||||
builder.delete_external_id("3");
|
||||
let result = builder.execute().unwrap();
|
||||
println!("{result:?}");
|
||||
|
||||
wtxn.commit().unwrap();
|
||||
index.delete_documents(vec!["0".into(), "3".into()]);
|
||||
|
||||
db_snap!(index, word_fid_docids, 3, @"4c2e2a1832e5802796edc1638136d933");
|
||||
db_snap!(index, word_position_docids, 3, @"74f556b91d161d997a89468b4da1cb8f");
|
||||
@ -2557,7 +2546,7 @@ mod tests {
|
||||
),
|
||||
]
|
||||
*/
|
||||
let mut index = TempIndex::new();
|
||||
let index = TempIndex::new();
|
||||
|
||||
// START OF BATCH
|
||||
|
||||
|
@ -142,9 +142,6 @@ pub fn write_into_lmdb_database_without_merging(
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::io::Cursor;
|
||||
use std::iter::FromIterator;
|
||||
|
||||
use roaring::RoaringBitmap;
|
||||
|
||||
use crate::db_snap;
|
||||
use crate::documents::{DocumentsBatchBuilder, DocumentsBatchReader};
|
||||
@ -335,22 +332,14 @@ mod tests {
|
||||
db_snap!(index, word_prefix_pair_proximity_docids, "initial");
|
||||
db_snap!(index, prefix_word_pair_proximity_docids, "initial");
|
||||
|
||||
let mut wtxn = index.write_txn().unwrap();
|
||||
let mut delete = DeleteDocuments::new(&mut wtxn, &index).unwrap();
|
||||
delete.delete_documents(&RoaringBitmap::from_iter([50]));
|
||||
delete.execute().unwrap();
|
||||
wtxn.commit().unwrap();
|
||||
index.delete_document("9000");
|
||||
|
||||
db_snap!(index, documents_ids, "first_delete");
|
||||
db_snap!(index, word_docids, "first_delete");
|
||||
db_snap!(index, word_prefix_pair_proximity_docids, "first_delete");
|
||||
db_snap!(index, prefix_word_pair_proximity_docids, "first_delete");
|
||||
|
||||
let mut wtxn = index.write_txn().unwrap();
|
||||
let mut delete = DeleteDocuments::new(&mut wtxn, &index).unwrap();
|
||||
delete.delete_documents(&RoaringBitmap::from_iter(0..50));
|
||||
delete.execute().unwrap();
|
||||
wtxn.commit().unwrap();
|
||||
index.delete_documents((0..50).map(|id| id.to_string()).collect());
|
||||
|
||||
db_snap!(index, documents_ids, "second_delete");
|
||||
db_snap!(index, word_docids, "second_delete");
|
||||
@ -417,23 +406,14 @@ mod tests {
|
||||
db_snap!(index, word_prefix_pair_proximity_docids, "initial");
|
||||
db_snap!(index, prefix_word_pair_proximity_docids, "initial");
|
||||
|
||||
let mut wtxn = index.write_txn().unwrap();
|
||||
let mut delete = DeleteDocuments::new(&mut wtxn, &index).unwrap();
|
||||
delete.delete_documents(&RoaringBitmap::from_iter([50]));
|
||||
delete.execute().unwrap();
|
||||
wtxn.commit().unwrap();
|
||||
index.delete_document("9000");
|
||||
|
||||
db_snap!(index, documents_ids, "first_delete");
|
||||
db_snap!(index, word_docids, "first_delete");
|
||||
db_snap!(index, word_prefix_pair_proximity_docids, "first_delete");
|
||||
db_snap!(index, prefix_word_pair_proximity_docids, "first_delete");
|
||||
|
||||
let mut wtxn = index.write_txn().unwrap();
|
||||
let mut delete = DeleteDocuments::new(&mut wtxn, &index).unwrap();
|
||||
|
||||
delete.delete_documents(&RoaringBitmap::from_iter(0..50));
|
||||
delete.execute().unwrap();
|
||||
wtxn.commit().unwrap();
|
||||
index.delete_documents((0..50).map(|id| id.to_string()).collect());
|
||||
|
||||
db_snap!(index, documents_ids, "second_delete");
|
||||
db_snap!(index, word_docids, "second_delete");
|
||||
|
@ -923,7 +923,7 @@ mod tests {
|
||||
use super::*;
|
||||
use crate::error::Error;
|
||||
use crate::index::tests::TempIndex;
|
||||
use crate::update::{ClearDocuments, DeleteDocuments};
|
||||
use crate::update::ClearDocuments;
|
||||
use crate::{Criterion, Filter, SearchResult};
|
||||
|
||||
#[test]
|
||||
@ -1768,13 +1768,9 @@ mod tests {
|
||||
}
|
||||
index.add_documents(documents! { docs }).unwrap();
|
||||
|
||||
let mut wtxn = index.write_txn().unwrap();
|
||||
let mut builder = DeleteDocuments::new(&mut wtxn, &index).unwrap();
|
||||
(0..5).for_each(|id| {
|
||||
builder.delete_external_id(&id.to_string());
|
||||
});
|
||||
builder.execute().unwrap();
|
||||
index.delete_documents((0..5).map(|id| id.to_string()).collect());
|
||||
|
||||
let mut wtxn = index.write_txn().unwrap();
|
||||
index
|
||||
.update_settings_using_wtxn(&mut wtxn, |settings| {
|
||||
settings.set_searchable_fields(vec!["id".to_string()]);
|
||||
|
Loading…
Reference in New Issue
Block a user