diff --git a/meilisearch-core/src/query_builder.rs b/meilisearch-core/src/query_builder.rs index 3f127c4c7..40cabc84c 100644 --- a/meilisearch-core/src/query_builder.rs +++ b/meilisearch-core/src/query_builder.rs @@ -97,14 +97,14 @@ impl<'c, 'f, 'd, 'i> QueryBuilder<'c, 'f, 'd, 'i> { .unwrap_or_default(); ors.push(docids); } - let sets: Vec<_> = ors.iter().map(|i| &i.1).map(Cow::deref).collect(); + let sets: Vec<_> = ors.iter().map(|(_, i)| i).map(Cow::deref).collect(); let or_result = sdset::multi::OpBuilder::from_vec(sets).union().into_set_buf(); ands.push(Cow::Owned(or_result)); ors.clear(); } Either::Right(key) => { match self.index.facets.facet_document_ids(reader, &key)? { - Some(docids) => ands.push(docids.1), + Some((_name, docids)) => ands.push(docids), // no candidates for search, early return. None => return Ok(Some(SetBuf::default())), } diff --git a/meilisearch-core/src/store/facets.rs b/meilisearch-core/src/store/facets.rs index 9a3dde6f9..a2a6fa3e9 100644 --- a/meilisearch-core/src/store/facets.rs +++ b/meilisearch-core/src/store/facets.rs @@ -2,12 +2,13 @@ use std::borrow::Cow; use std::collections::HashMap; use std::mem; -use heed::{RwTxn, RoTxn, Result as ZResult, RoRange, types::Str, BytesEncode, BytesDecode}; +use heed::{RwTxn, RoTxn, RoRange, types::Str, BytesEncode, BytesDecode}; use sdset::{SetBuf, Set, SetOperation}; use meilisearch_types::DocumentId; use meilisearch_schema::FieldId; +use crate::MResult; use crate::database::MainT; use crate::facets::FacetKey; use super::cow_set::CowSet; @@ -56,21 +57,21 @@ impl<'a> BytesDecode<'a> for FacetData { impl Facets { // we use sdset::SetBuf to ensure the docids are sorted. - pub fn put_facet_document_ids(&self, writer: &mut RwTxn, facet_key: FacetKey, doc_ids: &Set, facet_value: &str) -> ZResult<()> { - self.facets.put(writer, &facet_key, &(facet_value, doc_ids)) + pub fn put_facet_document_ids(&self, writer: &mut RwTxn, facet_key: FacetKey, doc_ids: &Set, facet_value: &str) -> MResult<()> { + Ok(self.facets.put(writer, &facet_key, &(facet_value, doc_ids))?) } - pub fn field_document_ids<'txn>(&self, reader: &'txn RoTxn, field_id: FieldId) -> ZResult> { - self.facets.prefix_iter(reader, &FacetKey::new(field_id, String::new())) + pub fn field_document_ids<'txn>(&self, reader: &'txn RoTxn, field_id: FieldId) -> MResult> { + Ok(self.facets.prefix_iter(reader, &FacetKey::new(field_id, String::new()))?) } - pub fn facet_document_ids<'txn>(&self, reader: &'txn RoTxn, facet_key: &FacetKey) -> ZResult>)>> { - self.facets.get(reader, &facet_key) + pub fn facet_document_ids<'txn>(&self, reader: &'txn RoTxn, facet_key: &FacetKey) -> MResult>)>> { + Ok(self.facets.get(reader, &facet_key)?) } /// updates the facets store, revmoving the documents from the facets provided in the /// `facet_map` argument - pub fn remove(&self, writer: &mut RwTxn, facet_map: HashMap)>) -> ZResult<()> { + pub fn remove(&self, writer: &mut RwTxn, facet_map: HashMap)>) -> MResult<()> { for (key, (name, document_ids)) in facet_map { if let Some((_, old)) = self.facets.get(writer, &key)? { let to_remove = SetBuf::from_dirty(document_ids); @@ -81,7 +82,7 @@ impl Facets { Ok(()) } - pub fn add(&self, writer: &mut RwTxn, facet_map: HashMap)>) -> ZResult<()> { + pub fn add(&self, writer: &mut RwTxn, facet_map: HashMap)>) -> MResult<()> { for (key, (facet_name, document_ids)) in facet_map { let set = SetBuf::from_dirty(document_ids); self.put_facet_document_ids(writer, key, set.as_set(), &facet_name)?; @@ -89,7 +90,7 @@ impl Facets { Ok(()) } - pub fn clear(self, writer: &mut heed::RwTxn) -> ZResult<()> { - self.facets.clear(writer) + pub fn clear(self, writer: &mut heed::RwTxn) -> MResult<()> { + Ok(self.facets.clear(writer)?) } }