Make the facet distinct work with the new split facets

This commit is contained in:
Clément Renault 2021-05-03 10:05:36 +02:00 committed by Kerollmops
parent bd7b285bae
commit e62b89a2ed
No known key found for this signature in database
GPG Key ID: 92ADA4E935E71FA4

View File

@ -25,13 +25,12 @@ pub struct FacetDistinct<'a> {
} }
impl<'a> FacetDistinct<'a> { impl<'a> FacetDistinct<'a> {
pub fn new( pub fn new(distinct: FieldId, index: &'a Index, txn: &'a heed::RoTxn<'a>) -> Self {
distinct: FieldId, Self {
index: &'a Index, distinct,
txn: &'a heed::RoTxn<'a>, index,
) -> Self txn,
{ }
Self { distinct, index, txn }
} }
} }
@ -100,10 +99,9 @@ impl<'a> FacetDistinctIter<'a> {
let mut candidates_iter = self.candidates.iter().skip(self.iter_offset); let mut candidates_iter = self.candidates.iter().skip(self.iter_offset);
match candidates_iter.next() { match candidates_iter.next() {
Some(id) => { Some(id) => {
match self.facet_type { // We distinct the document id on its facet strings and facet numbers.
FacetType::String => self.distinct_string(id)?, self.distinct_string(id)?;
FacetType::Number => self.distinct_number(id)?, self.distinct_number(id)?;
};
// The first document of each iteration is kept, since the next call to // The first document of each iteration is kept, since the next call to
// `difference_with` will filter out all the documents for that facet value. By // `difference_with` will filter out all the documents for that facet value. By