Skip to content

Commit

Permalink
Merge pull request #979 from slckl/main
Browse files Browse the repository at this point in the history
FacetCounts are now pub use in tantivy::collector (Closes #978)
  • Loading branch information
fulmicoton committed Feb 5, 2021
2 parents 86d92a7 + 769e9ba commit f099f97
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/collector/facet_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>(&self, facet_from: T) -> FacetChildIterator<'_>
where
Facet: From<T>,
Expand All @@ -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<T>(&self, facet: T, k: usize) -> Vec<(&Facet, u64)>
where
Facet: From<T>,
Expand Down
1 change: 1 addition & 0 deletions src/collector/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f099f97

Please sign in to comment.