mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 20:37:15 +02:00
Implement the IN filter operator
This commit is contained in:
parent
90a304cb07
commit
ca97cb0eda
2 changed files with 103 additions and 3 deletions
|
@ -362,6 +362,32 @@ impl<'a> Filter<'a> {
|
|||
)?;
|
||||
return Ok(all_ids - selected);
|
||||
}
|
||||
FilterCondition::In { fid, els } => {
|
||||
// TODO: this could be optimised
|
||||
let filterable_fields = index.filterable_fields(rtxn)?;
|
||||
|
||||
if crate::is_faceted(fid.value(), &filterable_fields) {
|
||||
let field_ids_map = index.fields_ids_map(rtxn)?;
|
||||
|
||||
if let Some(fid) = field_ids_map.id(fid.value()) {
|
||||
let mut bitmap = RoaringBitmap::new();
|
||||
|
||||
for el in els {
|
||||
let op = Condition::Equal(el.clone());
|
||||
let el_bitmap = Self::evaluate_operator(rtxn, index, fid, &op)?;
|
||||
bitmap |= el_bitmap;
|
||||
}
|
||||
Ok(bitmap)
|
||||
} else {
|
||||
Ok(RoaringBitmap::new())
|
||||
}
|
||||
} else {
|
||||
return Err(fid.as_external_error(FilterError::AttributeNotFilterable {
|
||||
attribute: fid.value(),
|
||||
filterable_fields,
|
||||
}))?;
|
||||
}
|
||||
}
|
||||
FilterCondition::Condition { fid, op } => {
|
||||
if crate::is_faceted(fid.value(), filterable_fields) {
|
||||
let field_ids_map = index.fields_ids_map(rtxn)?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue