From 498f0d8539c20ea4c314afd67387d6a113164cfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Fri, 20 Nov 2020 12:09:21 +0100 Subject: [PATCH] Output the documents count for each facet value in the infos subcommand --- src/subcommand/infos.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/subcommand/infos.rs b/src/subcommand/infos.rs index 4153b97b4..f8138660b 100644 --- a/src/subcommand/infos.rs +++ b/src/subcommand/infos.rs @@ -409,7 +409,7 @@ fn facet_values_docids(index: &Index, rtxn: &heed::RoTxn, debug: bool, field_nam let stdout = io::stdout(); let mut wtr = csv::Writer::from_writer(stdout.lock()); - wtr.write_record(&["facet_value", "documents_ids"])?; + wtr.write_record(&["facet_value", "documents_count", "documents_ids"])?; let db = index.facet_field_id_value_docids; let iter = facet_values_iter( @@ -424,12 +424,13 @@ fn facet_values_docids(index: &Index, rtxn: &heed::RoTxn, debug: bool, field_nam for result in iter { let (value, docids) = result?; + let count = docids.len(); let docids = if debug { format!("{:?}", docids) } else { format!("{:?}", docids.iter().collect::>()) }; - wtr.write_record(&[value, docids])?; + wtr.write_record(&[value, count.to_string(), docids])?; } Ok(wtr.flush()?)