From a482c0e966d2e98d3ef954ae3f5563cea2017af2 Mon Sep 17 00:00:00 2001 From: alif Date: Fri, 5 Feb 2021 09:00:48 +0200 Subject: [PATCH 1/2] pub use FacetCounts in tantivy::collector module --- src/collector/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/collector/mod.rs b/src/collector/mod.rs index 73fc432b72..6e567047ee 100644 --- a/src/collector/mod.rs +++ b/src/collector/mod.rs @@ -109,6 +109,7 @@ pub use self::tweak_score_top_collector::{ScoreSegmentTweaker, ScoreTweaker}; mod facet_collector; pub use self::facet_collector::FacetCollector; +pub use self::facet_collector::FacetCounts; use crate::query::Weight; mod docset_collector; From 769e9ba14df6fa06ba1cee72a0a1a92c80857354 Mon Sep 17 00:00:00 2001 From: alif Date: Fri, 5 Feb 2021 09:18:20 +0200 Subject: [PATCH 2/2] added simple docs to FacetCounts now-public API --- src/collector/facet_collector.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/collector/facet_collector.rs b/src/collector/facet_collector.rs index 6c9404e7f8..cd10cbaf06 100644 --- a/src/collector/facet_collector.rs +++ b/src/collector/facet_collector.rs @@ -398,6 +398,8 @@ impl<'a> Iterator for FacetChildIterator<'a> { } impl FacetCounts { + /// Returns an iterator over all of the facet count pairs inside this result. + /// See the documentation for `FacetCollector` for a usage example. pub fn get(&self, facet_from: T) -> FacetChildIterator<'_> where Facet: From, @@ -417,6 +419,8 @@ impl FacetCounts { FacetChildIterator { underlying } } + /// Returns a vector of top `k` facets with their counts, sorted highest-to-lowest by counts. + /// See the documentation for `FacetCollector` for a usage example. pub fn top_k(&self, facet: T, k: usize) -> Vec<(&Facet, u64)> where Facet: From,