Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot collect facets starting from the root in Tantivy 0.20 #2085

Closed
adamreichold opened this issue Jun 10, 2023 · 2 comments · Fixed by #2086
Closed

Cannot collect facets starting from the root in Tantivy 0.20 #2085

adamreichold opened this issue Jun 10, 2023 · 2 comments · Fixed by #2086

Comments

@adamreichold
Copy link
Collaborator

Applying the following diff

diff --git a/src/collector/facet_collector.rs b/src/collector/facet_collector.rs
index 6861a9faa..597e4ba12 100644
--- a/src/collector/facet_collector.rs
+++ b/src/collector/facet_collector.rs
@@ -119,17 +119,16 @@ fn facet_depth(facet_bytes: &[u8]) -> usize {
 ///
 ///     {
 ///         let mut facet_collector = FacetCollector::for_field("facet");
-///         facet_collector.add_facet("/lang");
-///         facet_collector.add_facet("/category");
+///         facet_collector.add_facet("/");
 ///         let facet_counts = searcher.search(&AllQuery, &facet_collector)?;
 ///
 ///         // This lists all of the facet counts
 ///         let facets: Vec<(&Facet, u64)> = facet_counts
-///             .get("/category")
+///             .get("/")
 ///             .collect();
 ///         assert_eq!(facets, vec![
-///             (&Facet::from("/category/biography"), 1),
-///             (&Facet::from("/category/fiction"), 3)
+///             (&Facet::from("/lang"), 4),
+///             (&Facet::from("/category"), 4)
 ///         ]);
 ///     }
 ///

to the example for FacetCollector makes it fail with

thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `[(Facet(/lang), 4)]`,
 right: `[(Facet(/lang), 4), (Facet(/category), 4)]`', src/collector/facet_collector.rs:59:9

using the just released Tantitvy version 0.20, i.e. it is not possible to collect facets starting with the root.

I am not sure what the problem is, but I suspect that compute_collapse_mapping_one does not handle facet_bytes.len() == 0 which is the case when collecting facets from the root.

@adamreichold
Copy link
Collaborator Author

I see that 0.20.1 was just released so I understand this will not happen immediately, but since this is the last known blocker for us to upgrade to 0.20.x, I would be glad if this could find its way into an upcoming bug fix release as well.

@PSeitz
Copy link
Contributor

PSeitz commented Jun 12, 2023

It's released with 0.20.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants