From a3e3bebed7d2f07872185b32d57d5eb5bdfecc7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Wed, 27 Jan 2021 18:29:54 +0100 Subject: [PATCH] Rework the FacetDistribution execute method to use the faceted_fields struct --- src/search/facet/facet_distribution.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/search/facet/facet_distribution.rs b/src/search/facet/facet_distribution.rs index 01f7b7205..fc3c72853 100644 --- a/src/search/facet/facet_distribution.rs +++ b/src/search/facet/facet_distribution.rs @@ -2,6 +2,7 @@ use std::collections::{HashSet, BTreeMap}; use std::ops::Bound::Unbounded; use std::{cmp, fmt}; +use anyhow::Context; use roaring::RoaringBitmap; use crate::facet::{FacetType, FacetValue}; @@ -194,7 +195,7 @@ impl<'a> FacetDistribution<'a> { } } - pub fn execute(&self) -> heed::Result>> { + pub fn execute(&self) -> anyhow::Result>> { let fields_ids_map = self.index.fields_ids_map(self.rtxn)?; let faceted_fields = self.index.faceted_fields(self.rtxn)?; let fields_ids: Vec<_> = match &self.facets { @@ -207,7 +208,9 @@ impl<'a> FacetDistribution<'a> { let mut facets_values = BTreeMap::new(); for (name, ftype) in fields_ids { - let fid = fields_ids_map.id(&name).unwrap(); + let fid = fields_ids_map.id(&name).with_context(|| { + format!("missing field name {:?} from the fields id map", name) + })?; let values = self.facet_values(fid, ftype)?; facets_values.insert(name, values); }