mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-12-25 06:00:08 +01:00
Merge #435
435: Ensure we get no documents and no error when filtering on an empty db r=Kerollmops a=irevoire Co-authored-by: Tamo <tamo@meilisearch.com>
This commit is contained in:
commit
74962b2fd9
@ -453,6 +453,32 @@ mod tests {
|
|||||||
use crate::update::Settings;
|
use crate::update::Settings;
|
||||||
use crate::Index;
|
use crate::Index;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn empty_db() {
|
||||||
|
let path = tempfile::tempdir().unwrap();
|
||||||
|
let mut options = EnvOpenOptions::new();
|
||||||
|
options.map_size(10 * 1024 * 1024); // 10 MB
|
||||||
|
let index = Index::new(options, &path).unwrap();
|
||||||
|
|
||||||
|
// Set the filterable fields to be the channel.
|
||||||
|
let mut wtxn = index.write_txn().unwrap();
|
||||||
|
let mut builder = Settings::new(&mut wtxn, &index);
|
||||||
|
builder.set_searchable_fields(vec![S("PrIcE")]); // to keep the fields order
|
||||||
|
builder.set_filterable_fields(hashset! { S("PrIcE") });
|
||||||
|
builder.execute(|_| ()).unwrap();
|
||||||
|
wtxn.commit().unwrap();
|
||||||
|
|
||||||
|
let rtxn = index.read_txn().unwrap();
|
||||||
|
|
||||||
|
let filter = Filter::from_str("PrIcE < 1000").unwrap().unwrap();
|
||||||
|
let bitmap = filter.evaluate(&rtxn, &index).unwrap();
|
||||||
|
assert!(bitmap.is_empty());
|
||||||
|
|
||||||
|
let filter = Filter::from_str("NOT PrIcE >= 1000").unwrap().unwrap();
|
||||||
|
let bitmap = filter.evaluate(&rtxn, &index).unwrap();
|
||||||
|
assert!(bitmap.is_empty());
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn from_array() {
|
fn from_array() {
|
||||||
// Simple array with Left
|
// Simple array with Left
|
||||||
|
Loading…
x
Reference in New Issue
Block a user