mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-07-28 09:11:00 +00:00
Merge the two <facetttype>_faceted_documents_ids methods into one
This commit is contained in:
committed by
Loïc Lecrenier
parent
982efab88f
commit
3d145d7f48
@ -1,7 +1,7 @@
|
||||
use roaring::RoaringBitmap;
|
||||
use time::OffsetDateTime;
|
||||
|
||||
use crate::{ExternalDocumentsIds, FieldDistribution, Index, Result};
|
||||
use crate::{facet::FacetType, ExternalDocumentsIds, FieldDistribution, Index, Result};
|
||||
|
||||
pub struct ClearDocuments<'t, 'u, 'i> {
|
||||
wtxn: &'t mut heed::RwTxn<'i, 'u>,
|
||||
@ -55,8 +55,18 @@ impl<'t, 'u, 'i> ClearDocuments<'t, 'u, 'i> {
|
||||
|
||||
// We clean all the faceted documents ids.
|
||||
for field_id in faceted_fields {
|
||||
self.index.put_number_faceted_documents_ids(self.wtxn, field_id, &empty_roaring)?;
|
||||
self.index.put_string_faceted_documents_ids(self.wtxn, field_id, &empty_roaring)?;
|
||||
self.index.put_faceted_documents_ids(
|
||||
self.wtxn,
|
||||
field_id,
|
||||
FacetType::Number,
|
||||
&empty_roaring,
|
||||
)?;
|
||||
self.index.put_faceted_documents_ids(
|
||||
self.wtxn,
|
||||
field_id,
|
||||
FacetType::String,
|
||||
&empty_roaring,
|
||||
)?;
|
||||
}
|
||||
|
||||
// Clear the other databases.
|
||||
|
@ -461,9 +461,15 @@ impl<'t, 'u, 'i> DeleteDocuments<'t, 'u, 'i> {
|
||||
// Remove the documents ids from the faceted documents ids.
|
||||
for field_id in self.index.faceted_fields_ids(self.wtxn)? {
|
||||
// Remove docids from the number faceted documents ids
|
||||
let mut docids = self.index.number_faceted_documents_ids(self.wtxn, field_id)?;
|
||||
let mut docids =
|
||||
self.index.faceted_documents_ids(self.wtxn, field_id, FacetType::Number)?;
|
||||
docids -= &self.to_delete_docids;
|
||||
self.index.put_number_faceted_documents_ids(self.wtxn, field_id, &docids)?;
|
||||
self.index.put_faceted_documents_ids(
|
||||
self.wtxn,
|
||||
field_id,
|
||||
FacetType::Number,
|
||||
&docids,
|
||||
)?;
|
||||
|
||||
remove_docids_from_field_id_docid_facet_value(
|
||||
self.wtxn,
|
||||
@ -474,9 +480,15 @@ impl<'t, 'u, 'i> DeleteDocuments<'t, 'u, 'i> {
|
||||
)?;
|
||||
|
||||
// Remove docids from the string faceted documents ids
|
||||
let mut docids = self.index.string_faceted_documents_ids(self.wtxn, field_id)?;
|
||||
let mut docids =
|
||||
self.index.faceted_documents_ids(self.wtxn, field_id, FacetType::String)?;
|
||||
docids -= &self.to_delete_docids;
|
||||
self.index.put_string_faceted_documents_ids(self.wtxn, field_id, &docids)?;
|
||||
self.index.put_faceted_documents_ids(
|
||||
self.wtxn,
|
||||
field_id,
|
||||
FacetType::String,
|
||||
&docids,
|
||||
)?;
|
||||
|
||||
remove_docids_from_field_id_docid_facet_value(
|
||||
self.wtxn,
|
||||
@ -648,7 +660,7 @@ fn remove_docids_from_facet_id_docids<'a>(
|
||||
if !modified {
|
||||
return Ok(());
|
||||
}
|
||||
let builder = FacetsUpdateBulk::new(index, facet_type);
|
||||
let builder = FacetsUpdateBulk::new_not_updating_level_0(index, facet_type);
|
||||
builder.execute(wtxn)?;
|
||||
|
||||
Ok(())
|
||||
|
Reference in New Issue
Block a user